A function to insert a byte into a slice is conspicuous by its absence. Consider this code to parse /proc/meminfo into a 2D array and insert commas:
MemTotal: 497464 kB MemFree: 386232 kB MemAvailable: 452420 kB Buffers: 8612 kB Cached: 60160 kB ... . aLine := bytes.SplitN(fileBuf, []byte("\n"), 6) var aPair [5][][]byte for a := 0; a < 5; a++ { aPair[a] = bytes.SplitN(aLine[a], []byte(":"), 2) aPair[a][1] = sRegEx.FindSubmatch(aPair[a][1])[1] // " *([0-9]+)" if len(aPair[a][1]) > 3 { // should be: // aPair[a][1] = bytes.InsertByte(aPair[a][1], len(aPair[a][1])-3, ',') // but instead it's gobbledygook: aPair[a][1] = aPair[a][1][:len(aPair[a][1])+1] copy(aPair[a][1][len(aPair[a][1])-2:], aPair[a][1][len(aPair[a][1])-3:]) aPair[a][1][len(aPair[a][1])-4] = ',' } } Surely this is common enough to merit inclusion in stdlib. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.