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.

22 lines
499 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. // +build plan9
  5. package plan9
  6. func itoa(val int) string { // do it here rather than with fmt to avoid dependency
  7. if val < 0 {
  8. return "-" + itoa(-val)
  9. }
  10. var buf [32]byte // big enough for int64
  11. i := len(buf) - 1
  12. for val >= 10 {
  13. buf[i] = byte(val%10 + '0')
  14. i--
  15. val /= 10
  16. }
  17. buf[i] = byte(val + '0')
  18. return string(buf[i:])
  19. }