Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

DocumentIterator usage can corrupt data if you forget to zero/nil your buffer

オープン 初心者向け
#39 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
領域
databases

調査の方向性

documentdb パッケージにある DocumentIterator の実装を確認します。おそらく iterator.go のようなファイルにあります。反復のたびに slice の参照がどのように再利用されているかを調べます。修正では、各反復で buffer をクリアするか、新しい slice を割り当てるようにします。修正前と修正後でサンプルコードを実行し、データの破損が防止されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Since it is a slice reference, any nested structs or arrays in your data will be sparsely overwritten during iteration and can still include old data from past iteration if you follow the docs:

	// ...
	var docs []Document

	iterator := documentdb.NewIterator(
		client, documentdb.NewDocumentIterator("coll_self_link", nil, &docs, documentdb.PartitionKey("1"), documentdb.Limit(1)),
	)

	for iterator.Next() {
		if err := iterator.Error(); err != nil {
			log.Fatal(err)
		}
		fmt.Println(len(docs))
	}    

	// ...
}```

Instead, nil the buffer like this:

func main() {
// ...
var docs []Document

iterator := documentdb.NewIterator(
	client, documentdb.NewDocumentIterator("coll_self_link", nil, &docs, documentdb.PartitionKey("1"), documentdb.Limit(1)),
)

for iterator.Next() {
	if err := iterator.Error(); err != nil {
		log.Fatal(err)
	}
	fmt.Println(len(docs))
            docs = nil // zero your buffer to avoid corrupt data!
}    

// ...

}```

主要言語
Go
スター
31
フォーク
26
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

a8m/documentdb のほかの issue

a8m/documentdb の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。