Menu

Go Explained: Simple Code That Runs Fast
πŸ“°

Go Explained: Simple Code That Runs Fast

DEV Community: goΒ·The Practical DeveloperΒ·about 1 hour ago
#QIdKAxu4
#devtogo#devto#dev#done#goroutines
Reading 0:00
15s threshold

Introduction

Go was built at Google for a specific frustration: large programs that were slow to build and hard to read. The answer was a language that is deliberately small β€” fewer features, but the right ones, done well.

If you know one programming language already, Go will feel familiar within an hour. The interesting parts are not the syntax, but two ideas: goroutines and channels.

Goroutines: cheap concurrency

Most languages make running things at the same time feel heavy β€” threads, thread pools, and careful setup. A goroutine is Go's lightweight version: you start one by writing go in front of a function call.

package main

import ( "fmt" "time" )

func say ( text string ) { for i := 0 ; i < 3 ; i ++ { fmt . Println ( text ) time . Sleep ( 100 * time . Millisecond ) } }

func main () { go say ( "hello" ) say ( "world" ) time . Sleep ( 500 * time .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.