Skip to content

Instantly share code, notes, and snippets.

@marcoscouto
Last active January 27, 2024 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoscouto/50d7dde7f7f0ee0b163486b0ed38c46a to your computer and use it in GitHub Desktop.
Save marcoscouto/50d7dde7f7f0ee0b163486b0ed38c46a to your computer and use it in GitHub Desktop.
Golang - Extension function
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