Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created June 4, 2022 22:52
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 xeoncross/e8fbea4f1537bb1b0fdae7385fc79d74 to your computer and use it in GitHub Desktop.
Save xeoncross/e8fbea4f1537bb1b0fdae7385fc79d74 to your computer and use it in GitHub Desktop.
Example of creating a string that implements an interface in Go / golang: https://go.dev/play/p/-IC8BGzjPPG
package main
import "fmt"
type A string
func (a A) Foo() {
fmt.Printf("Foo: %q\n", a)
}
type Fooer interface {
Foo()
}
func main() {
var a Fooer
a = A("hello")
a.Foo()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment