Skip to content

golangci-lint: Fix some trivial issues#53

Open
mjtrangoni wants to merge 8 commits intozabbix-tools:masterfrom
mjtrangoni:fix-some-lint-errors
Open

golangci-lint: Fix some trivial issues#53
mjtrangoni wants to merge 8 commits intozabbix-tools:masterfrom
mjtrangoni:fix-some-lint-errors

Conversation

@mjtrangoni
Copy link

Hi @cavaliercoder,

This PR fix some trivial issues detected by golangci-lint. If you agree I can go further and fix the non-trivial ones in a separate PR, adding also a CI check.

See,
bool.go:17:10: S1028: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (gosimple)
                return errors.New(fmt.Sprintf("Boolean unmarshal error: invalid input %s", asString))
                       ^

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
See,
debug.go:9:11: var-declaration: should omit type bool from declaration of var debug; it will be inferred from the right-hand side (revive)
var debug bool = (os.Getenv("ZBX_DEBUG") == "1")
          ^
maintenance.go:145:1: receiver-naming: receiver name c should be consistent with previous receiver name m for MaintenanceCreateParams (revive)
func (c *MaintenanceCreateParams) FillFields(Object *Maintenance) *MaintenanceCreateParams {
        c.ActiveSince = Object.ActiveSince.Unix()
        c.ActiveTill = Object.ActiveSince.Add(time.Hour * time.Duration(Object.ServicePeriod)).Unix()
        c.Description = Object.Description
        c.MaintenanceID = Object.MaintenanceID
        c.Name = Object.Name
        c.TagsEvaltype = int(Object.Type)
        c.MaintenanceType = int(Object.ActionEvalTypeAndOr)

        return c
}

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
See,
client_builder_test.go:5:2: SA1019: "io/ioutil" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
        "io/ioutil"
        ^

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
See,
maintenance.go:134:7: SA6005: should use strings.EqualFold instead (staticcheck)
                        if strings.ToUpper(strings.Trim(host.Hostname, " ")) == strings.ToUpper(strings.Trim(name, " ")) {
                           ^

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
See,
time.go:15:23: SA5009: Printf format %s has arg zabbix-tools#1 of wrong type int64 (staticcheck)
        stamp := fmt.Sprintf("\"%s\"", t.Unix())
                             ^

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
Copy link
Collaborator

@cavaliercoder cavaliercoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thank you! Please proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants