Skip to content

Instantly share code, notes, and snippets.

@philiplambok
Created September 18, 2022 07:29
Show Gist options
  • Save philiplambok/b912756e68c8e16071a8f4a169c608b9 to your computer and use it in GitHub Desktop.
Save philiplambok/b912756e68c8e16071a8f4a169c608b9 to your computer and use it in GitHub Desktop.
go methods
package main
import "fmt"
type Person struct {
FirstName string
LastName string
}
func (p Person) fullName() string {
return fmt.Sprintf("%s %s", p.FirstName, p.LastName)
}
func main() {
person := Person{"Bill", "John"}
fmt.Println(person.fullName())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment