Build fast backend services with Go.
Learn Go fundamentals for web development.
Hello World
package main
import “fmt”
func main() {
fmt.Println(“Hello, World!”)
}
Variables
var name string = “John”
age := 30 // Type inference
Functions
func add(a, b int) int {
return a + b
}
Goroutines
go func() {
fmt.Println(“Running concurrently”)
}()
Channels
ch := make(chan string)
go func() { ch <- "message" }()
msg := <-ch
Web Framework
// Gin
r := gin.Default()
r.GET(“/ping”, func(c *gin.Context) {
c.JSON(200, gin.H{“message”: “pong”})
})
Conclusion
Go is perfect for high-performance backend services!