Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hadihammurabi/got
Golang result building
https://github.com/hadihammurabi/got
Last synced: 9 days ago
JSON representation
Golang result building
- Host: GitHub
- URL: https://github.com/hadihammurabi/got
- Owner: hadihammurabi
- Created: 2022-03-09T05:20:55.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-10T00:19:51.000Z (almost 3 years ago)
- Last Synced: 2024-11-07T08:38:58.453Z (about 2 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# got
Golang result building# Examples
```go
func IsOdd(num int) got.Result {
if num%2 == 0 {
return got.Err(fmt.Sprintf("%d is not odd", num))
}return got.Ok(true)
}func GetAllContacts(num int) got.Result {
result := make(chan got.Result)go func() {
resp, err := goreq.Get("https://my-json-server.typicode.com/hadihammurabi/flutter-webservice/contacts", nil)
if err != nil {
result <- got.Err(err.Error())
}
defer resp.Body.Close()var data interface{}
err = resp.Json(&data)
if err != nil {
result <- got.Err(err.Error())
}result <- got.Ok(data)
}()res := <-result
return res
}
```