Skip to content

Instantly share code, notes, and snippets.

@kognate
Created October 26, 2012 21:02
Show Gist options
  • Save kognate/3961465 to your computer and use it in GitHub Desktop.
Save kognate/3961465 to your computer and use it in GitHub Desktop.
go function with returns
package main
import "fmt"
type AThing struct {
Public string
private int64
}
func (a *AThing) ireturn(onearg int64) (int64, error) {
// because this is in the same package as the AThing I
// can access it's private members
iaminferedtype := a.private + onearg;
return iaminferedtype, nil
}
func main() {
a := AThing{"hello", 50}
b,_ := a.ireturn(50)
fmt.Printf("Hai: %d\n",b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment