Skip to content

Instantly share code, notes, and snippets.

@AndreiD
Created September 30, 2018 09:18
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 AndreiD/8544114d27e2c4a140e8a13c7bc1a43e to your computer and use it in GitHub Desktop.
Save AndreiD/8544114d27e2c4a140e8a13c7bc1a43e to your computer and use it in GitHub Desktop.
simpleapp
package gotomobile
import "fmt"
func SayHello() {
fmt.Println("Hello!")
}
func SayHelloWithName(name string) {
fmt.Println("Hello! " + name)
}
// this returns an error if name is not x
func ThisReturnsAnError(name string) error {
if name != "x" {
return fmt.Errorf("name is not x")
}
return nil
}
func Returns2Arguments(firstName, LastName string) (string, error) {
if LastName != "x" {
return "", fmt.Errorf("eerror")
}
return LastName + LastName, nil
}
// This will not work. Second result value must be of type error
//func Returns2Arguments(firstName, LastName string) (string, string) {
// return LastName, firstName
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment