Skip to content

Commit

Permalink
Merge pull request #28 from tekintian/master
Browse files Browse the repository at this point in the history
replace deprecated  func of go v20
  • Loading branch information
dengsgo authored Jun 1, 2024
2 parents 3d8d855 + 5f7b909 commit b3f4bf4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package main

import (
"io/ioutil"
"os"
"os/exec"
"runtime"
Expand Down Expand Up @@ -38,13 +37,13 @@ func runAsDaemon() (int, error) {
}
pid := daemon.Process.Pid
if pid != 0 {
ioutil.WriteFile(getPidFile(), []byte(strconv.Itoa(pid)), 0644)
os.WriteFile(getPidFile(), []byte(strconv.Itoa(pid)), 0644)
}
return pid, nil
}

func stopDaemon() error {
bs, err := ioutil.ReadFile(getPidFile())
bs, err := os.ReadFile(getPidFile())
if err != nil {
return nil
}
Expand Down
11 changes: 5 additions & 6 deletions fileboy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"os"
Expand Down Expand Up @@ -63,7 +62,7 @@ type changedFile struct {

func parseConfig() {
cfg = new(FileGirl)
fc, err := ioutil.ReadFile(getFileGirlPath())
fc, err := os.ReadFile(getFileGirlPath())
if err != nil {
logError("the filegirl configuration file is not exist! ", err)
fmt.Print(firstRunHelp)
Expand Down Expand Up @@ -216,7 +215,7 @@ func watchChangeHandler(event fsnotify.Event) {
if event.Op != fsnotify.Create && event.Op != fsnotify.Rename {
return
}
_, err := ioutil.ReadDir(event.Name)
_, err := os.ReadDir(event.Name)
if err != nil {
return
}
Expand Down Expand Up @@ -288,12 +287,12 @@ func parseArgs() {
logUInfo("fileboy daemon is stoped.")
return
case "init":
_, err := ioutil.ReadFile(getFileGirlPath())
_, err := os.ReadFile(getFileGirlPath())
if err == nil {
logError("profile filegirl already exists.")
logAndExit("delete it first when you want to regenerate filegirl conf file")
}
err = ioutil.WriteFile(getFileGirlPath(), []byte(exampleFileGirl), 0644)
err = os.WriteFile(getFileGirlPath(), []byte(exampleFileGirl), 0644)
if err != nil {
logError("profile filegirl create failed! ", err)
return
Expand Down Expand Up @@ -337,7 +336,7 @@ func getFileGirlPath() string {

func show() {
fmt.Print(logo)
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano())) // rand.Seed is deprecated: As of Go 1.20
fmt.Println(englishSay[rand.Intn(len(englishSay))])
fmt.Println("")
fmt.Println(statement)
Expand Down
3 changes: 1 addition & 2 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package main

import (
"io/ioutil"
"log"
"os"
"runtime"
Expand Down Expand Up @@ -69,7 +68,7 @@ func hitDirs(d string, dirs *[]string) bool {
}

func listFile(folder string, fun func(string)) {
files, _ := ioutil.ReadDir(folder)
files, _ := os.ReadDir(folder)
for _, file := range files {
if file.IsDir() {
d := folder + "/" + file.Name()
Expand Down

0 comments on commit b3f4bf4

Please sign in to comment.