Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hadihammurabi/got

Golang result building
https://github.com/hadihammurabi/got

Last synced: 9 days ago
JSON representation

Golang result building

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
}
```