Skip to content

Instantly share code, notes, and snippets.

@reiver
Created December 27, 2013 04:59
Show Gist options
  • Save reiver/8142758 to your computer and use it in GitHub Desktop.
Save reiver/8142758 to your computer and use it in GitHub Desktop.
One way of copying between arrays of different sizes, in #golang (i.e., Go). Is this the most efficient way of doing it?
package main
import "fmt"
func main() {
var a [9]uint8
fmt.Printf("a = %v\n", a)
b := [3]uint8{1, 2, 3}
copy( a[0:3] , b[0:3] )
fmt.Printf("a = %v\n", a)
c := [3]uint8{4, 5, 6}
copy( a[3:6] , c[0:3] )
fmt.Printf("a = %v\n", a)
d := [3]uint8{7, 8, 9}
copy( a[6:9] , d[0:3] )
fmt.Printf("a = %v\n", a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment