emahiro/b.log

Drastically Repeat Yourself !!!!

2019-12-20から1日間の記事一覧

Go で n 番目の要素を削除する

go

大した話じゃないんですけど、忘れてたので備忘録です。 strs := []string{"a", "b", "c", "d", "e"} // "c" を削除する。 idx := 2 strs = append(strs[:idx], strs[idx+1:]...) fmt.Println(strs) ref: https://play.golang.org/p/3QP4OXw2X0u