Skip to content

Commit b8919a8

Browse files
authored
Update the attributes map instead of using the map provided by the user, preventing two maps from actually being the same reference (#179)
1 parent a999520 commit b8919a8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x' ]
13+
go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x' ]
1414
steps:
1515
- name: Set up Go ${{ matrix.go }}
1616
uses: actions/setup-go@v4
@@ -26,9 +26,9 @@ jobs:
2626
go get -v -t -d ./...
2727
2828
- name: Lint
29-
uses: golangci/golangci-lint-action@v3
29+
uses: golangci/golangci-lint-action@v6
3030
with:
31-
version: v1.51.2
31+
version: v1.58
3232

3333
- name: Test
3434
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

graph.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ func EdgeAttribute(key, value string) func(*EdgeProperties) {
335335
// [graph.Graph.UpdateEdge] methods.
336336
func EdgeAttributes(attributes map[string]string) func(*EdgeProperties) {
337337
return func(e *EdgeProperties) {
338-
e.Attributes = attributes
338+
for k, v := range attributes {
339+
e.Attributes[k] = v
340+
}
339341
}
340342
}
341343

@@ -382,6 +384,8 @@ func VertexAttribute(key, value string) func(*VertexProperties) {
382384
// of a vertex. This is a functional option for the [graph.Graph.AddVertex] methods.
383385
func VertexAttributes(attributes map[string]string) func(*VertexProperties) {
384386
return func(e *VertexProperties) {
385-
e.Attributes = attributes
387+
for k, v := range attributes {
388+
e.Attributes[k] = v
389+
}
386390
}
387391
}

0 commit comments

Comments
 (0)