Health Tracker - Go Typing CST Test
Loading…
Health Tracker — Go Code
Tracks health with concurrent damage and healing operations.
package main
import (
"fmt"
"sync"
)
func main() {
health := 100
var mu sync.Mutex
var wg sync.WaitGroup
damage := func() {
mu.Lock()
health -= 20
fmt.Println("Health:", health)
mu.Unlock()
}
heal := func() {
mu.Lock()
health += 10
fmt.Println("Health:", health)
mu.Unlock()
}
wg.Add(2)
go func() { defer wg.Done(); damage() }()
go func() { defer wg.Done(); heal() }()
wg.Wait()
}Go Language Guide
Go (Golang) is a statically typed, compiled programming language designed at Google. It emphasizes simplicity, concurrency, and high-performance networking and system programming, making it ideal for cloud services, web backends, and distributed systems.
Primary Use Cases
- ▸Backend web services and APIs
- ▸Cloud-native and distributed systems
- ▸Command-line utilities
- ▸Network programming and microservices
- ▸DevOps and infrastructure tooling
Notable Features
- ▸Compiled and statically typed with fast binaries
- ▸Goroutines and channels for concurrency
- ▸Automatic memory management via garbage collection
- ▸Powerful standard library, especially for networking and web
- ▸Cross-platform compilation support
Origin & Creator
Created by Robert Griesemer, Rob Pike, and Ken Thompson at Google in 2007 and publicly released in 2009.
Industrial Note
Go is specialized for backend systems, cloud infrastructure, networking, and concurrent applications rather than heavy GUI or mobile frontend development.