Skip to content

Instantly share code, notes, and snippets.

@chardos
Last active January 23, 2019 23:31
Show Gist options
  • Save chardos/047e05ebe90464ad4fabf7d25cc57822 to your computer and use it in GitHub Desktop.
Save chardos/047e05ebe90464ad4fabf7d25cc57822 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
// make a slice, without starting length off 0
s := make([]string, 0)
// above is same as
// s := []string{}
s = append(s, "hello")
fmt.Println(len(s)) // prints length of s
// initiate it with some values inside
s2 := []string{"a","b","c"}
// iterate it
for k, v := range s3 {
fmt.Println(k, v)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment