mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2026-02-13 14:41:45 +01:00
Fix QF1004: could use strings.ReplaceAll instead (staticcheck)
This commit is contained in:
@@ -187,7 +187,7 @@ func getBaseFreq() float64 {
|
||||
for _, f := range files {
|
||||
buffer, err := os.ReadFile(f)
|
||||
if err == nil {
|
||||
data := strings.Replace(string(buffer), "\n", "", -1)
|
||||
data := strings.ReplaceAll(string(buffer), "\n", "")
|
||||
x, err := strconv.ParseInt(data, 0, 64)
|
||||
if err == nil {
|
||||
freq = float64(x)
|
||||
|
||||
@@ -1291,8 +1291,8 @@ func (m *NvidiaCollector) Read(interval time.Duration, output chan lp.CCMessage)
|
||||
if ret == nvml.SUCCESS {
|
||||
mname, ret := nvml.DeviceGetName(mdev)
|
||||
if ret == nvml.SUCCESS {
|
||||
x := strings.Replace(mname, name, "", -1)
|
||||
x = strings.Replace(x, "MIG", "", -1)
|
||||
x := strings.ReplaceAll(mname, name, "")
|
||||
x = strings.ReplaceAll(x, "MIG", "")
|
||||
x = strings.TrimSpace(x)
|
||||
migDevice.tags["stype-id"] = x
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (m *TempCollector) Init(config json.RawMessage) error {
|
||||
sensor.metricName = sensor.label
|
||||
}
|
||||
sensor.metricName = strings.ToLower(sensor.metricName)
|
||||
sensor.metricName = strings.Replace(sensor.metricName, " ", "_", -1)
|
||||
sensor.metricName = strings.ReplaceAll(sensor.metricName, " ", "_")
|
||||
// Add temperature prefix, if required
|
||||
if !strings.Contains(sensor.metricName, "temp") {
|
||||
sensor.metricName = "temp_" + sensor.metricName
|
||||
|
||||
@@ -238,7 +238,7 @@ func matchfunc(args ...interface{}) (interface{}, error) {
|
||||
case string:
|
||||
switch total := args[1].(type) {
|
||||
case string:
|
||||
smatch := strings.Replace(match, "%", "\\", -1)
|
||||
smatch := strings.ReplaceAll(match, "%", "\\")
|
||||
regex, err := regexp.Compile(smatch)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
Reference in New Issue
Block a user