Skip to content

Instantly share code, notes, and snippets.

@alfianmalik
Created May 24, 2020 16:23
Show Gist options
  • Save alfianmalik/97228f7c03c026d895f300656f2c5df2 to your computer and use it in GitHub Desktop.
Save alfianmalik/97228f7c03c026d895f300656f2c5df2 to your computer and use it in GitHub Desktop.
package errors
import (
"fmt"
)
func printError(err bool, m string) string {
if err {
message = "You have encountered an error"
// Attempting to set 'message' to anything other than a string will result
// in a compiler error
}
return message
}
m := printError(true, "")
fmt.Println(m) // "You have encountered an error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment