[Solved] Continue loop after 404 response


This question leaks details that because it earned so much down-votes. I assumed that we are dealing with a Get method of UserService in go-jira.

The Get method returns error:

func (s *UserService) Get(username string) (*User, *Response, error)

You are omitting error check and pulling it to a blank identifier. Note that if an error returned with a non-nil value then the *User is nil.

resp, err := s.client.Do(req, user)
if err != nil {
    return nil, resp, err
}

And if even I incorrectly assumed a lib which you are using it is a Go way to handle the situation. The proper way is to check error value and do what you need but not wait until your program face nil pointer dereference.

  user, resp, err := jiraClient.User.Get()
  if err != nil {
      // Do something clever...
  }

Errors are values

Furthermore error is an interface. So error could contain some useful data or be an object of a concrete type.

An error variable represents any value that can describe itself as a string. Here is the interface’s declaration:

type error interface {
    Error() string
}

1

solved Continue loop after 404 response