Refactor Exported Names to Follow Golang Best Practices (#13075)

* Fix exported names that start with a package name

* A few more renames

* Fix exported names that start with a package name

* A few more renames

* Radek's feedback

* Fix conflict

* fix keymanager test

* Fix comments

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terencechain
2023-10-20 09:45:33 -07:00
committed by GitHub
parent 65ce27292c
commit 9387a36b66
146 changed files with 1625 additions and 1625 deletions

View File

@@ -92,7 +92,7 @@ func WriteFile(file string, data []byte) error {
if err != nil {
return err
}
if FileExists(expanded) {
if Exists(expanded) {
info, err := os.Stat(expanded)
if err != nil {
return err
@@ -141,9 +141,9 @@ func HasReadWritePermissions(itemPath string) (bool, error) {
return info.Mode() == params.BeaconIoConfig().ReadWritePermissions, nil
}
// FileExists returns true if a file is not a directory and exists
// Exists returns true if a file is not a directory and exists
// at the specified path.
func FileExists(filename string) bool {
func Exists(filename string) bool {
filePath, err := ExpandPath(filename)
if err != nil {
return false
@@ -201,7 +201,7 @@ func ReadFileAsBytes(filename string) ([]byte, error) {
// CopyFile copy a file from source to destination path.
func CopyFile(src, dst string) error {
if !FileExists(src) {
if !Exists(src) {
return errors.New("source file does not exist at provided path")
}
f, err := os.Open(src) // #nosec G304

View File

@@ -131,7 +131,7 @@ func TestWriteFile_OK(t *testing.T) {
require.NoError(t, err)
someFileName := filepath.Join(dirName, "somefile.txt")
require.NoError(t, file.WriteFile(someFileName, []byte("hi")))
exists := file.FileExists(someFileName)
exists := file.Exists(someFileName)
assert.Equal(t, true, exists)
}
@@ -182,8 +182,8 @@ func TestCopyDir(t *testing.T) {
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir1, "subfolder2"), 0777))
for _, fd := range fds {
require.NoError(t, file.WriteFile(filepath.Join(tmpDir1, fd.path), fd.content))
assert.Equal(t, true, file.FileExists(filepath.Join(tmpDir1, fd.path)))
assert.Equal(t, false, file.FileExists(filepath.Join(tmpDir2, fd.path)))
assert.Equal(t, true, file.Exists(filepath.Join(tmpDir1, fd.path)))
assert.Equal(t, false, file.Exists(filepath.Join(tmpDir2, fd.path)))
}
// Make sure that files are copied into non-existent directory only. If directory exists function exits.
@@ -192,7 +192,7 @@ func TestCopyDir(t *testing.T) {
// Now, all files should have been copied.
for _, fd := range fds {
assert.Equal(t, true, file.FileExists(filepath.Join(tmpDir2, fd.path)))
assert.Equal(t, true, file.Exists(filepath.Join(tmpDir2, fd.path)))
assert.Equal(t, true, deepCompare(t, filepath.Join(tmpDir1, fd.path), filepath.Join(tmpDir2, fd.path)))
}
assert.Equal(t, true, file.DirsEqual(tmpDir1, tmpDir2))