I am a new to Go and have a question. Maybe it is not a idiomatic Go code but just for studying purposes how to make this code work? It seems that I can put as a receiver type of int, but how to call it in main?:
xa.go
package main
import "fmt"
type xa int
func (xl xa) print() {
fmt.Println(xl)
}
main.go
package main
func main() {
X := (xa{2})//not working
X.print()
}
Run:
go run main.go xa.go
.\main.go:10:8: invalid composite literal type xa