package main
import "fmt"
type User struct {
Name string
}
var user User
func main() {
fmt.Println(user)
}
package main
import "fmt"
func main() {
x := 1
y := &x
fmt.Println(*y)
*y = 2
fmt.Println(x)
}
package main
import "fmt"
func main() {
defer func() { fmt.Println("A") }()
go func() { fmt.Println("C") }()
fmt.Println("B")
}
package main
import "fmt"
import "encoding/json"
type Event struct {
Name string
Data interface{}
}
var e Event = Event{"x", "y"}
func main() {
str, _ := json.Marshal(e)
fmt.Println(str)
}
EXPECTED OUTPUT: {"name":"x","data":"y"}
Write a minimal thread pool using go routines and channels.
Requirements:
- Use 3 workers
- Program should receive a json file like following
['{URL_TO_IMAGE}', ...]
as first paramdemo ./images.json
- All files should be stored in
./data
folder ( Create folder if missing ) - For each download print the following:
- #X - Downloading http://example.com/path-to-image...
- #X - Completed http://example.com/path-to-image...
#X is the id of the thread number ( #1 - .... )
Done when:
- A file name
demo.go
is provided - It successfully compile
- The binary output meets requirements