Skip to content

Instantly share code, notes, and snippets.

@eminetto
Last active June 5, 2020 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminetto/5c191aae65db8f74e94b6da97eda211c to your computer and use it in GitHub Desktop.
Save eminetto/5c191aae65db8f74e94b6da97eda211c to your computer and use it in GitHub Desktop.
can.go
//this way?
func CanSubscribe(userID int, courseID int) bool {
}
//this way?
func CanSubscribe(userID int, courseID int) error {
//if can't subscribe return an error
//if can return nil
//if there's an error, like a database connection error, return the error itself
}
//or this way?
func CanSubscribe(userID int, courseID int) (bool, error) {
//if can't subscribe return an false and an error
//if can return true and nil
//if there's an error return false and an error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment