named type

tags: learning go programming

content

type Count int
  • getting very confused because i completely forgot that this is just a named type
  • it’s not a struct
  • methods can be added to a named type, just like with struct
type Count int
func (c Count) String() string {
	return strconv.Itoa(int(c))
}

Note

it’s not a single field struct

  • this is a single field struct:
type Count struct {
	Value int,
}

up

down

reference