Last active
August 7, 2018 03:01
-
-
Save pulkitkumar/e553f483d493995348f5eddf5dfd210a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package user | |
import ( | |
"net/http" | |
"github.com/pkg/errors" | |
) | |
type User struct { | |
Name string | |
Email string | |
} | |
func FetchStruct() (User, error) { | |
var u User | |
resp, err := http.Get("url") | |
if err != nil { | |
return u, errors.Wrap(err, "network read error") | |
} | |
u = User{ | |
Name: "some data from resp", | |
Email: "some data from resp", | |
} | |
return u, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment