str.go 504 B

12345678910111213141516171819202122
  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 windows
  5. package windows
  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. }