Skip to content

Commit

Permalink
all: Reformat with gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Jan 28, 2024
1 parent 718ae15 commit 78170c3
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 15 deletions.
1 change: 0 additions & 1 deletion cmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func init() {
// clean cleans the cache, excluding the version installed with the "install"
// command.
func clean() error {

cacheSize, err := getCacheSize()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func initConfig() {
// Create config directory.
userConfigDir, err := os.UserConfigDir()
cobra.CheckErr(err)
err = os.MkdirAll(filepath.Join(userConfigDir, App.Name), 0777)
err = os.MkdirAll(filepath.Join(userConfigDir, App.Name), 0o777)
cobra.CheckErr(err)

// Define config file.
Expand Down Expand Up @@ -167,6 +167,6 @@ func initApp() {
App.DotFilePath = filepath.Join(wd, App.DotFileName)
App.WorkingDir = wd

err = os.MkdirAll(App.CacheDirPath, 0777)
err = os.MkdirAll(App.CacheDirPath, 0o777)
cobra.CheckErr(err)
}
1 change: 0 additions & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func getCacheSize() (int64, error) {

return nil
})

if err != nil {
return 0, err
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ tag to an .hvm file.`,
func init() {
rootCmd.AddCommand(useCmd)
useCmd.Flags().Bool("useVersionInDotFile", false, "Use the version specified by the "+App.DotFileName+" file\nin the current directory")

}

// A repository is a GitHub repository.
Expand Down Expand Up @@ -277,7 +276,6 @@ func (r *repository) selectTag(a *asset, msg string) error {
fmt.Printf("%-25s", fmt.Sprintf("%3d) %s %s", i+1, tag, flag))
if (i+1)%3 == 0 {
fmt.Print("\n")

} else if i == len(tags)-1 {
fmt.Print("\n")
}
Expand Down Expand Up @@ -422,7 +420,7 @@ func (a *asset) getExecPath() string {

// createDotFile creates an application dot file in the current directory.
func (a *asset) createDotFile() error {
err := os.WriteFile(App.DotFilePath, []byte(a.tag), 0644)
err := os.WriteFile(App.DotFilePath, []byte(a.tag), 0o644)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/archive/extract_targz.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func extractTarGZ(src string, dst string) error {
switch th.Typeflag {
case tar.TypeDir:
if _, err := os.Stat(target); err != nil {
if err := os.MkdirAll(target, 0777); err != nil {
if err := os.MkdirAll(target, 0o777); err != nil {
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/archive/extract_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func extractZip(src string, dst string) error {
target := filepath.Join(dst, f.Name)

if f.FileInfo().IsDir() {
err = os.MkdirAll(target, 0777)
err = os.MkdirAll(target, 0o777)
if err != nil {
return err
}
continue
}

err := os.MkdirAll(filepath.Dir(target), 0777)
err := os.MkdirAll(filepath.Dir(target), 0o777)
if err != nil {
return err
}
Expand All @@ -68,7 +68,7 @@ func copyFileFromZip(z *zip.File, dst string) error {
}
defer zrc.Close()

df, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR, 0777)
df, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR, 0o777)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func CopyFile(src string, dst string) error {
}
defer s.Close()

err = os.MkdirAll(filepath.Dir(dst), 0777)
err = os.MkdirAll(filepath.Dir(dst), 0o777)
if err != nil {
return err
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func CopyDirectoryContent(src string, dst string) error {
}

target := filepath.Join(dst, strings.TrimPrefix(path, src))
err = os.MkdirAll(filepath.Dir(target), 0777)
err = os.MkdirAll(filepath.Dir(target), 0o777)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestIsEmpty(t *testing.T) {
dPathNotEmpty := t.TempDir()
fPathNotEmpty := filepath.Join(dPathNotEmpty, "not-empty-file.txt")

err = os.WriteFile(fPathNotEmpty, []byte("not empty"), 0644)
err = os.WriteFile(fPathNotEmpty, []byte("not empty"), 0o644)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -314,7 +314,6 @@ func TestCopyDirectoryContent(t *testing.T) {
if want != got {
t.Errorf("file content is incorrect: want %q got %q", want, got)
}

}

func TestRemoveDirectoryContent(t *testing.T) {
Expand Down

0 comments on commit 78170c3

Please sign in to comment.