Created
September 18, 2022 07:29
-
-
Save philiplambok/b912756e68c8e16071a8f4a169c608b9 to your computer and use it in GitHub Desktop.
go methods
This file contains hidden or 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 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