Skip to content

Instantly share code, notes, and snippets.

View wesleymatosdev's full-sized avatar

wesleymatosdev

View GitHub Profile
package main
import "fmt"
func main() {
hello := []string{"h", "e", "l", "l", "o"}
world := []string{"w", "o", "r", "l", "d"}
fullHello := hello[:]
fmt.Println(fullHello)
a[0:10]
a[:10]
a[0:]
a[:]
var a [10]string
[]string{"h", "e", "l", "l", "o"}
package main
import "fmt"
func main() {
names := [4]string{
"John",
"Paul",
"George",
"Ringo",
// _Slices_ are a key data type in Go, giving a more
// powerful interface to sequences than arrays.
package main
import "fmt"
func main() {
// Unlike arrays, slices are typed only by the
c := make([]string, len(s))
copy(c, s)
fmt.Println("copy: ", c)
s := make([]int, 0)
s = append(s, "h", "e", "l", "l", "o")
s = append(s, " ")
s = append(s, "w", "o", "r", "l" "d")
fmt.Println("append: " s)
s := make([]int, 5)
package main
import "fmt"
func main() {
var a [2]string
a[0] = "Hello"
a[1] = "World"
fmt.Println(a[0], a[1])
fmt.Println(a)