Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Functions are declared thusly
- // func function_name(varname vartype, ...) vartype { }
- func example(x int, y int) int {
- return x * y
- }
- func example2( x, y int) int {
- return x + y
- }
- func example3(x, y int) (int, string) {
- return (x*y), "Use i,s := example3(5, 9)"
- }
- func example4(x int) (y, z int) {
- // Here the return variables are explicitly named in the function declaration
- y = x / 10
- z = x * 10
- // This allows us to do a naked return with implicit values
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement