Skip to content

Commit

Permalink
Fix gosimple issues
Browse files Browse the repository at this point in the history
See,

$ golangci-lint run --disable-all --enable=gosimple
handle_latest_data.go:79:29: S1019: should use make(chan error) instead (gosimple)
			errs := make(chan error, 0)
			                         ^
trigger.go:66:10: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
	date := time.Now().Sub(trigger.date())
	        ^
zabbix.go:119:5: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
	if time.Now().Sub(stat.ModTime()).Seconds() < ZabbixSessionTTL {
	   ^

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
  • Loading branch information
mjtrangoni committed Apr 13, 2019
1 parent 780dd44 commit 4c925ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion handle_latest_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func handleLatestData(
err = withSpinner(
":: Requesting information about hosts items & web scenarios",
func() error {
errs := make(chan error, 0)
errs := make(chan error)

go func() {
var err error
Expand Down
8 changes: 4 additions & 4 deletions trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func (trigger *Trigger) String() string {
}

func (trigger *Trigger) GetHostName() string {
if len(trigger.Hosts) > 0 {
if len(trigger.Hosts) > 0 {
return trigger.Hosts[0].Name
}
return "<missing>"
}
return "<missing>"
}

func (trigger *Trigger) StatusAcknowledge() string {
Expand Down Expand Up @@ -63,7 +63,7 @@ func (trigger *Trigger) DateTime() string {
}

func (trigger *Trigger) Age() string {
date := time.Now().Sub(trigger.date())
date := time.Since(trigger.date())

var (
seconds = int(date.Seconds()) % 60
Expand Down
2 changes: 1 addition & 1 deletion zabbix.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (zabbix *Zabbix) restoreSession(path string) error {
)
}

if time.Now().Sub(stat.ModTime()).Seconds() < ZabbixSessionTTL {
if time.Since(stat.ModTime()).Seconds() < ZabbixSessionTTL {
session, err := ioutil.ReadAll(file)
if err != nil {
return karma.Format(
Expand Down

0 comments on commit 4c925ea

Please sign in to comment.