From 41ec2aaf273d9f94456bdfa05160763d2a7f364c Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 15 Sep 2021 21:12:02 +0200 Subject: [PATCH] chore: run lint fixer Signed-off-by: Mark Sagi-Kazar --- viper.go | 2 +- viper_test.go | 18 +++++++++--------- watch.go | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/viper.go b/viper.go index 6c456a9..0b27c19 100644 --- a/viper.go +++ b/viper.go @@ -267,7 +267,7 @@ func New() *Viper { v := new(Viper) v.keyDelim = "." v.configName = "config" - v.configPermissions = os.FileMode(0644) + v.configPermissions = os.FileMode(0o644) v.fs = afero.NewOsFs() v.config = make(map[string]interface{}) v.override = make(map[string]interface{}) diff --git a/viper_test.go b/viper_test.go index 464fce0..f614cf8 100644 --- a/viper_test.go +++ b/viper_test.go @@ -263,13 +263,13 @@ func initDirs(t *testing.T) (string, string, func()) { require.Nil(t, err) for _, dir := range testDirs { - err = os.Mkdir(dir, 0750) + err = os.Mkdir(dir, 0o750) assert.Nil(t, err) err = ioutil.WriteFile( path.Join(dir, config+".toml"), []byte("key = \"value is "+dir+"\"\n"), - 0640) + 0o640) assert.Nil(t, err) } @@ -441,7 +441,7 @@ func TestReadInConfig(t *testing.T) { t.Run("config file set", func(t *testing.T) { fs := afero.NewMemMapFs() - err := fs.Mkdir("/etc/viper", 0777) + err := fs.Mkdir("/etc/viper", 0o777) require.NoError(t, err) file, err := fs.Create(testutil.AbsFilePath(t, "/etc/viper/config.yaml")) @@ -2290,7 +2290,7 @@ func newViperWithConfigFile(t *testing.T) (*Viper, string, func()) { watchDir, err := ioutil.TempDir("", "") require.Nil(t, err) configFile := path.Join(watchDir, "config.yaml") - err = ioutil.WriteFile(configFile, []byte("foo: bar\n"), 0640) + err = ioutil.WriteFile(configFile, []byte("foo: bar\n"), 0o640) require.Nil(t, err) cleanup := func() { os.RemoveAll(watchDir) @@ -2307,11 +2307,11 @@ func newViperWithSymlinkedConfigFile(t *testing.T) (*Viper, string, string, func watchDir, err := ioutil.TempDir("", "") require.Nil(t, err) dataDir1 := path.Join(watchDir, "data1") - err = os.Mkdir(dataDir1, 0777) + err = os.Mkdir(dataDir1, 0o777) require.Nil(t, err) realConfigFile := path.Join(dataDir1, "config.yaml") t.Logf("Real config file location: %s\n", realConfigFile) - err = ioutil.WriteFile(realConfigFile, []byte("foo: bar\n"), 0640) + err = ioutil.WriteFile(realConfigFile, []byte("foo: bar\n"), 0o640) require.Nil(t, err) cleanup := func() { os.RemoveAll(watchDir) @@ -2355,7 +2355,7 @@ func TestWatchFile(t *testing.T) { }) v.WatchConfig() // when overwriting the file and waiting for the custom change notification handler to be triggered - err = ioutil.WriteFile(configFile, []byte("foo: baz\n"), 0640) + err = ioutil.WriteFile(configFile, []byte("foo: baz\n"), 0o640) wg.Wait() // then the config value should have changed require.Nil(t, err) @@ -2378,10 +2378,10 @@ func TestWatchFile(t *testing.T) { wg.Add(1) // when link to another `config.yaml` file dataDir2 := path.Join(watchDir, "data2") - err := os.Mkdir(dataDir2, 0777) + err := os.Mkdir(dataDir2, 0o777) require.Nil(t, err) configFile2 := path.Join(dataDir2, "config.yaml") - err = ioutil.WriteFile(configFile2, []byte("foo: baz\n"), 0640) + err = ioutil.WriteFile(configFile2, []byte("foo: baz\n"), 0o640) require.Nil(t, err) // change the symlink using the `ln -sfn` command err = exec.Command("ln", "-sfn", dataDir2, path.Join(watchDir, "data")).Run() diff --git a/watch.go b/watch.go index c433a8f..b5523b8 100644 --- a/watch.go +++ b/watch.go @@ -1,3 +1,4 @@ +//go:build !js // +build !js package viper