Diep's Blog
  • Home
Subscribe
Tagged

golang

A collection of 1 post

go

Go common pitfall #1: slice appending

Go's slice is simple to use, but there are some easy to make mistakes if you are not aware of its internals. For example, with following program: package main import "fmt" func main() { healthyFoods := []string{"orange", "apple", "lettuce"} myFoods := healthyFoods[0:2] myFoods = append(myFoods, "bacon") fmt.Println(healthyFoods) } You

  • Diep Pham
Diep Pham Sep 25, 2022 • 1 min read
Diep's Blog © 2023
  • Data & privacy
  • Contact
  • Contribute →
Powered by Ghost