News for hackers. Stuff that matters.
Re:Sum Types in Go by colin_mccabe on Friday December 26, 2014 @04:59AM (#8798566)
When I say "type MyInt int" didn't I just type-alias int?

No, you created a new type.

  cmccabe@keter:~/tmp> cat inta.go
  package main
  import "fmt"
  type myfoo int
  func printint(i int) {
    fmt.Printf("i = %d\n", i)
  }
  func main() {
    var foo myfoo
    printint(foo)
  }
  cmccabe@keter:~/tmp> go build inta.go 
  # command-line-arguments
  ./inta.go:13: cannot use foo (type myfoo) as type int in   argument to printint
You are probably thinking about "typedef" in C++, but go works differently in this case.

There are no comments on this comment yet.