Last active
January 27, 2024 22:36
-
-
Save marcoscouto/50d7dde7f7f0ee0b163486b0ed38c46a to your computer and use it in GitHub Desktop.
Golang - Extension function
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" | |
func main() { | |
t := Type{ | |
Message: "OK", | |
} | |
ct := CustomType(t) | |
fmt.Println(ct.Print()) | |
} | |
type Type struct { | |
Message string | |
} | |
type CustomType Type | |
func (t *CustomType) Print() string { | |
return fmt.Sprintf("Original message is %s", t.Message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment