Skip to content

Commit

Permalink
fixed some staticchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
r7wx committed Jun 17, 2023
1 parent d5b02ce commit 54ef530
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ func Unmarshal(configBytes []byte) (*Config, error) {
}
}

return nil, fmt.Errorf("Invalid configuration file format")
return nil, fmt.Errorf("invalid configuration file format")
}
7 changes: 3 additions & 4 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"io/ioutil"
"os"
"testing"
)
Expand Down Expand Up @@ -60,7 +59,7 @@ func TestLoadEnv(t *testing.T) {
}

func TestLoadFile(t *testing.T) {
cfgFile, err := ioutil.TempFile(".", "easy_gate_test_")
cfgFile, err := os.CreateTemp(".", "easy_gate_test_")
if err != nil {
t.Fatal(err)
}
Expand All @@ -71,7 +70,7 @@ func TestLoadFile(t *testing.T) {
}
defer os.Remove(cfgFile.Name())

cfgFile, err = ioutil.TempFile(".", "easy_gate_test_")
cfgFile, err = os.CreateTemp(".", "easy_gate_test_")
if err != nil {
t.Fatal(err)
}
Expand All @@ -82,7 +81,7 @@ func TestLoadFile(t *testing.T) {
}
defer os.Remove(cfgFile.Name())

cfgFile, err = ioutil.TempFile(".", "easy_gate_test_")
cfgFile, err = os.CreateTemp(".", "easy_gate_test_")
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"crypto/sha256"
"encoding/hex"
"io/ioutil"
"io"
"os"
)

Expand All @@ -20,7 +20,7 @@ func Load(filePath string) (*Config, string, error) {
}
defer cfgFile.Close()

fileData, _ := ioutil.ReadAll(cfgFile)
fileData, _ := io.ReadAll(cfgFile)
return loadConfig(fileData)
}

Expand Down
6 changes: 3 additions & 3 deletions internal/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func isURL(url string) bool {

func validateConfig(cfg *Config) error {
if !isHexColor(cfg.Theme.Background) {
return fmt.Errorf("Invalid background color")
return fmt.Errorf("invalid background color")
}
if !isHexColor(cfg.Theme.Foreground) {
return fmt.Errorf("Invalid foreground color")
return fmt.Errorf("invalid foreground color")
}

for _, service := range cfg.Services {
if !isURL(service.URL) {
return fmt.Errorf("Invalid URL for service %s", service.Name)
return fmt.Errorf("invalid URL for service %s", service.Name)
}
}

Expand Down
3 changes: 1 addition & 2 deletions internal/routine/routine_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package routine

import (
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -29,7 +28,7 @@ func TestMain(m *testing.M) {
"services": [],
"notes": []
}`
cfgFile, err := ioutil.TempFile(".", "easy_gate_test_")
cfgFile, err := os.CreateTemp(".", "easy_gate_test_")
if err != nil {
log.Fatal("Unable to write tmp files for test")
}
Expand Down

0 comments on commit 54ef530

Please sign in to comment.