整型转字符串

strconv.Itoa()

  1. package main
  2. import (
  3. "fmt"
  4. "reflect"
  5. "strconv"
  6. )
  7. type Integer int
  8. func (i *Integer) String() string {
  9. return strconv.Itoa(int(*i))
  10. }
  11. func main() {
  12. a := Integer(1111)
  13. a1 := a.String()
  14. fmt.Println(reflect.TypeOf(a1))
  15. }