https://github.com/luillyfe/synack-api-golang
https://github.com/luillyfe/synack-api-golang
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/luillyfe/synack-api-golang
- Owner: luillyfe
- Created: 2020-11-18T02:00:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-23T16:40:36.000Z (over 5 years ago)
- Last Synced: 2025-03-15T07:22:05.106Z (over 1 year ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Concurrency in go
It describe how to make concurrent http request using channels, how to parse json into Structs and custom its fields.
## Installation
Take a look at [go commands](https://golang.org/cmd/go/) for more details.
```bash
go build -o /yourfoldertodeploy .
go run /yourfoldertodeploy/yourexecfile
```
## Concurrenry using channels
```go
go func(ch chan []googleItems) {
var bing googleResponse
err := json.Unmarshal(searchOnBing(query), &bing)
if err != nil {
log.Fatal(err)
}
ch <- bing.Items
}(ch)
go func(ch chan []googleItems) {
var google googleResponse
err := json.Unmarshal(searchOnGoogle(query), &google)
if err != nil {
log.Fatal(err)
}
ch <- bing.Items
}(ch)
responseJSON, _ := json.Marshal(&response{Bing: <-ch, Google: <-ch})
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)