Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Panic will appear when running this demo.

Open
#15 3 comments 0 reactions 0 assignees View on GitHub

@sidsri14 is already working on this.

Since Jul 26, 2026.

  • #23 by @sidsri14 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go
Domain
databases, search

Research direction

Start by running the Go demo from the issue and reproducing the panic. Then inspect the elevator lookup around searchPoint = layer.nodes[*elevator]; done means the shown demo completes without panicking and the cause at that lookup is addressed.

Written by the indexing model from the issue text.

Description

Panic will appear when running this demo.

package main

import (
	"math/rand"
	"sync"
	"time"

	"github.com/coder/hnsw"
)

var (
	idToEmb = map[int64][]float32{
		8832462: {0.16308737, -0.015082314, -0.13542788, 0.0050275815},
		8836285: {0.12513474, -0.01645081, -0.18823123, 0.0038108851},
		8833448: {0.12430125, -0.028154016, -0.16484132, -0.013979792},
		8835979: {0.11317906, -0.015129599, -0.081378885, 0.14409661},
		8833623: {0.047779884, -0.01809181, -0.11893867, -0.042758342},
		8836020: {0.16370028, -0.018596498, -0.13393748, -0.025386846},
		8833095: {0.13081397, -0.011383214, -0.043572865, 0.007917681},
		105126:  {0.087190986, -0.013881853, -0.16933066, 0.09613177},
	}
)

func test2() {
	g := &hnsw.Graph[int64]{
		Distance: hnsw.CosineDistance,
		Rng:      rand.New(rand.NewSource(time.Now().UnixNano())),
		M:        32,
		Ml:       0.28,
		EfSearch: 300,
	}
	wg := sync.WaitGroup{}
	mtx := sync.Mutex{}
	for id, emb := range idToEmb {
		wg.Add(1)
		go func(id int64, emb []float32) {
			mtx.Lock()
			g.Add(hnsw.MakeNode(id, emb))
			mtx.Unlock()
			wg.Done()
		}(id, emb)
	}
	wg.Wait()

	for id, emb := range idToEmb {
		g.Add(hnsw.MakeNode(id, emb))
	}

}

func main() {
	test2()
}

There should be something wrong here.

if elevator != nil {
	searchPoint = layer.nodes[*elevator]
}
Dominant language
Go
Stars
240
Forks
34
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/hnsw

All issues in coder/hnsw

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.