code: func (s *Session) Logout(ctx context.Context) error {
  
  	if !s.engine.session.HasToken() {
  		return &apitypes.Error{
  			Type: apitypes.UnauthorizedError,
  			Err:  []string{"You must be logged in, to logout!"},
  		}
  	}
  
  	tok := s.engine.session.Token()
  	err := s.engine.client.Tokens.Delete(ctx, string(tok[:]))
  	switch err := err.(type) {
  	case *apitypes.Error:
  		switch err.Type {
  		case apitypes.InternalServerError:
  
  			// On a 5XX response, we don't know for sure that the server
  			// has successfully removed the auth token. Keep the copy in
  			// the daemon, so the user may try again.
  			return err
  		case apitypes.NotFoundError, apitypes.BadRequestError, apitypes.UnauthorizedError:
  			// A 4XX error indicates either the token isn't found, or we're
  			// not allowed to remove it (or the server is a teapot).
  			//
  			// In any case, the daemon has gotten out of sync with the
  			// server. Remove our local copy of the auth token.
  			log.Printf("Got 4XX removing auth token. Treating as success")
  			logoutErr := s.engine.session.Logout()
  			if logoutErr != nil {
  				return logoutErr
  			}
  
  			return nil
  		}
  	case nil:
  		logoutErr := s.engine.session.Logout()
  		if logoutErr != nil {
  			return logoutErr
  		}
  
  		return nil
  	default:
  		return err
  	}
  
  	return nil
  }
docs: // Logout destroys the current session if it exists, otherwise, it returns an
  // error that the request could not be completed.