Skip to content

Instantly share code, notes, and snippets.

@nobeans
Last active June 10, 2020 01:17
Show Gist options
  • Save nobeans/4d21cc85146b6fc9dff56455d95324fc to your computer and use it in GitHub Desktop.
Save nobeans/4d21cc85146b6fc9dff56455d95324fc to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
l1 := make([]string, 0, 0)
fmt.Println(append(l1, "1"))
fmt.Println(append(l1, "2"))
fmt.Println(append(l1, "3"))
fmt.Println(append(l1, "4"), append(l1, "5"), append(l1, "6"))
fmt.Println(append(l1, "7"))
// =>
// [1]
// [2]
// [3]
// [4] [5] [6]
// [7]
l2 := make([]string, 0, 1)
fmt.Println(append(l2, "1"))
fmt.Println(append(l2, "2"))
fmt.Println(append(l2, "3"))
fmt.Println(append(l2, "4"), append(l2, "5"), append(l2, "6"))
fmt.Println(append(l2, "7"))
// =>
// [1]
// [2]
// [3]
// [6] [6] [6] <---- !!!
// [7]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment