fix: improve code format (#2665)

* feat: replace io/ioutils pacakage with io/os package

* fix: add missing error handling
This commit is contained in:
dacongda
2024-02-01 23:06:12 +08:00
committed by GitHub
parent 0918757e85
commit e593f5be5b
8 changed files with 26 additions and 9 deletions

View File

@ -16,7 +16,6 @@ package util
import (
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
@ -40,7 +39,7 @@ func GetPath(path string) string {
func ListFiles(path string) []string {
res := []string{}
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
panic(err)
}

View File

@ -14,10 +14,10 @@
package util
import "io/ioutil"
import "os"
func GetUploadXlsxPath(fileId string) string {
file, err := ioutil.TempFile("", fileId)
file, err := os.CreateTemp("", fileId)
if err != nil {
panic(err)
}

View File

@ -119,6 +119,9 @@ func GetVersionInfo() (*VersionInfo, error) {
}
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})
if err != nil {
return res, err
}
commitOffset := 0
version := ""

View File

@ -70,6 +70,9 @@ func TestGetVersion(t *testing.T) {
testHash := plumbing.NewHash("f8bc87eb4e5ba3256424cf14aafe0549f812f1cf")
cIter, err := r.Log(&git.LogOptions{From: testHash})
if err != nil {
t.Log(err)
}
aheadCnt := 0
releaseVersion := ""