Last active
November 7, 2020 19:54
-
-
Save HallexCosta/ccced1b9977d2367862e22744d873d11 to your computer and use it in GitHub Desktop.
Example usage method with receiver in golang
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 main | |
import ( | |
"fmt" | |
) | |
type User struct { | |
Name string | |
} | |
func (user *User) Save() bool { | |
fmt.Println(map[string]interface{}{ | |
"name": user.Name, | |
"success": true, | |
}) | |
return true | |
} | |
func main() { | |
user := User{ | |
Name: "Hállex", | |
} | |
saved := user.Save() | |
if saved == true { | |
fmt.Println("Saved successfully") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment