Skip to content

Instantly share code, notes, and snippets.

@pitakill
Created December 13, 2016 16:48
Show Gist options
  • Save pitakill/c25583d59dbe94851ecffd81f8ae83a7 to your computer and use it in GitHub Desktop.
Save pitakill/c25583d59dbe94851ecffd81f8ae83a7 to your computer and use it in GitHub Desktop.
Test in Go
// Process consumes URL strings from stdin.
// Process must GET each URL and count "Go" substring in response.
// After all URLs are processed, process should print total number of "Go"
// occurences, e.g.:
//
// $ echo -e 'https://golang.org\nhttps://golang.org\nhttps://golang.org' | go run 1.go
// Count for https://golang.org: 9
// Count for https://golang.org: 9
// Count for https://golang.org: 9
// Total: 27
//
// Each URL should be handled right after reading it, in parallel with
// reading other URLs. There should be no more that k=5 concurrent URL
// handlers. URL handlers must not spawn other goroutines, e.g. if k=1000
// and there are no URLs to handle, there should be no 1000 goroutines.
//
// Don't use global variables. Use only standard library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment