You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
705 B

  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
  5. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
  6. package unix
  7. func itoa(val int) string { // do it here rather than with fmt to avoid dependency
  8. if val < 0 {
  9. return "-" + uitoa(uint(-val))
  10. }
  11. return uitoa(uint(val))
  12. }
  13. func uitoa(val uint) string {
  14. var buf [32]byte // big enough for int64
  15. i := len(buf) - 1
  16. for val >= 10 {
  17. buf[i] = byte(val%10 + '0')
  18. i--
  19. val /= 10
  20. }
  21. buf[i] = byte(val + '0')
  22. return string(buf[i:])
  23. }