How to implement an interface with a type in Go

1 Answer

0 votes
package main

import "fmt"

type IN interface {
	F()
}

type ST struct {
	str string
}

func (s ST) F() {
	fmt.Println(s.str)
}

func main() {
	var in IN = ST{"Go"}
	
	in.F()
}


/*
run:

Go

*/

 



answered Mar 30, 2020 by avibootz
...