Skip to content

Instantly share code, notes, and snippets.

@pulkitkumar
Last active August 10, 2018 12:38
Show Gist options
  • Save pulkitkumar/f992ff66f8a4a21a0c43c7512ae46ce7 to your computer and use it in GitHub Desktop.
Save pulkitkumar/f992ff66f8a4a21a0c43c7512ae46ce7 to your computer and use it in GitHub Desktop.
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
}
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