Theme Toggle - Go Typing CST Test
Loading…
Theme Toggle — Go Code
Toggles a dark/light theme flag concurrently.
package main
import (
"fmt"
"sync"
)
func main() {
var isDark bool
var mu sync.Mutex
var wg sync.WaitGroup
toggle := func() {
mu.Lock()
isDark = !isDark
fmt.Println("Theme:", map[bool]string{true: "Dark", false: "Light"}[isDark])
mu.Unlock()
}
for i := 0; i < 3; i++ {
wg.Add(1)
go func() { defer wg.Done(); toggle() }()
}
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.