Created
September 30, 2018 09:18
-
-
Save AndreiD/8544114d27e2c4a140e8a13c7bc1a43e to your computer and use it in GitHub Desktop.
simpleapp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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