github-vet / github-vet/rangeloop-pointer-findings

yadisnel/go-ms: runtime/kubernetes/kubernetes.go; 30 LoC

Open
#12,220 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [yadisnel/go-ms](https://www.github.com/yadisnel/go-ms) at [runtime/kubernetes/kubernetes.go](https://github.com/yadisnel/go-ms/blob/400e4ca1a38a70b728eaa16840b37625c34e6863/runtime/kubernetes/kubernetes.go#L107-L136)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> reference to kservice was used in a composite literal at line 119

[Click here to see the code in its original context.](https://github.com/yadisnel/go-ms/blob/400e4ca1a38a70b728eaa16840b37625c34e6863/runtime/kubernetes/kubernetes.go#L107-L136)

Click here to show the 30 line(s) of Go which triggered the analyzer.

```go
for _, kservice := range serviceList.Items {
// name of the service
name := kservice.Metadata.Labels["name"]
// version of the service
version := kservice.Metadata.Labels["version"]

srv := &service{
Service: &runtime.Service{
Name: name,
Version: version,
Metadata: make(map[string]string),
},
kservice: &kservice,
}

// set the address
address := kservice.Spec.ClusterIP
port := kservice.Spec.Ports[0]
srv.Service.Metadata["address"] = fmt.Sprintf("%s:%d", address, port.Port)
// set the type of service
srv.Service.Metadata["type"] = kservice.Metadata.Labels["go-ms"]

// copy annotations metadata into service metadata
for k, v := range kservice.Metadata.Annotations {
srv.Service.Metadata[k] = v
}

// save as service
svcMap[name+version] = srv
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 400e4ca1a38a70b728eaa16840b37625c34e6863

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.