Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
GitHub repository
I have a few more patterns to demonstrate that have been provided in the GitHub on the 100 days of Golang repository.
Awesome Go projects and frmaeworks
package main import ( "fmt" "net/http" "sync" ) func pingGoogle(c chan string, wg *sync.WaitGroup) { defer wg.Done() res, _ := http.Get("http://google.com") c <- res.Status } func pingDuckDuckGo(c chan string, wg *sync.WaitGroup) { defer wg.Done() res, _ := http.Get("https://duckduckgo.com") c <- res.Status } func pingBraveSearch(c chan string, wg *sync.WaitGroup) { defer wg.Done() res, _ := http.Get("https://search.brave.com") c <- res.Status } func main() { gogChan := make(chan string) ddgChan := make(chan string) braveChan := make(chan string) var wg sync.WaitGroup wg.Add(3) go pingDuckDuckGo(ddgChan, &wg) go pingGoogle(gogChan, &wg) go pingBraveSearch(braveChan, &wg) openChannels := 3 go func() { wg.Wait() close(gogChan) close(ddgChan) close(braveChan) }() for openChannels > 0 { select { case msg1, ok := <-gogChan: if !ok { openChannels-- } else { fmt.Println("Google responded:", msg1) } case msg2, ok := <-ddgChan: if !ok { openChannels-- } else { fmt.Println("DuckDuckGo responded:", msg2) } case msg3, ok := <-braveChan: if !ok { openChannels-- } else { fmt.Println("BraveSearch responded:", msg3) } } } }
Related posts
- Why Go is great choice for Software engineering.
- Golang Web: GET Method
- I'm coming from Java and I have been told that I'm writing go like I'm writing Java. Basically creating structs, injecting fields, and attaching methods. What else can I do?
- Como deixar o Swagger com tema dark mode usando Swaggo e Golang
- Gorilla,wow