Skip to content

Commit

Permalink
fix: update the Attributes map, instead of using the map provided by …
Browse files Browse the repository at this point in the history
…the user, preventing two maps from actually being the same reference (issue #177)
  • Loading branch information
tzq0301 committed Jun 15, 2024
1 parent 7d3171f commit 29ebd7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x' ]
go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x' ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v4
Expand All @@ -26,9 +26,9 @@ jobs:
go get -v -t -d ./...
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.51.2
version: v1.58

- name: Test
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
Expand Down
8 changes: 6 additions & 2 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ func EdgeAttribute(key, value string) func(*EdgeProperties) {
// [graph.Graph.UpdateEdge] methods.
func EdgeAttributes(attributes map[string]string) func(*EdgeProperties) {
return func(e *EdgeProperties) {
e.Attributes = attributes
for k, v := range attributes {
e.Attributes[k] = v
}
}
}

Expand Down Expand Up @@ -382,6 +384,8 @@ func VertexAttribute(key, value string) func(*VertexProperties) {
// of a vertex. This is a functional option for the [graph.Graph.AddVertex] methods.
func VertexAttributes(attributes map[string]string) func(*VertexProperties) {
return func(e *VertexProperties) {
e.Attributes = attributes
for k, v := range attributes {
e.Attributes[k] = v
}
}
}

0 comments on commit 29ebd7f

Please sign in to comment.