Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace io/ioutil to os based on new Go standard #481

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package main

import (
"encoding/json"
"io/ioutil"
"os"
"sort"
"strconv"
"strings"
Expand All @@ -37,7 +37,7 @@ type EmojiOne struct {
func loadEmojiOne(dataFile string) (*TrieNode, error) {
var trie = NewTrie()
var c = map[string]EmojiOne{}
var data, err = ioutil.ReadFile(dataFile)
var data, err = os.ReadFile(dataFile)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions mactab.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -135,9 +134,9 @@ func OpenMactabFile(engineName string) {
efPath := getMactabFile(engineName)
if _, err := os.Stat(efPath); os.IsNotExist(err) {
sampleFile := getEngineSubFile(sampleMactabFile)
sample, err := ioutil.ReadFile(sampleFile)
sample, err := os.ReadFile(sampleFile)
log.Println(err)
ioutil.WriteFile(efPath, sample, 0644)
os.WriteFile(efPath, sample, 0644)
}

err := exec.Command("/usr/lib/ibus-bamboo/macro-editor", efPath).Start()
Expand Down
5 changes: 2 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"os/user"
Expand Down Expand Up @@ -182,7 +181,7 @@ func loadConfig(engineName string) *Config {
}

setupConfigDir(engineName)
data, err := ioutil.ReadFile(getConfigPath(engineName))
data, err := os.ReadFile(getConfigPath(engineName))
if err == nil {
json.Unmarshal(data, &c)
}
Expand All @@ -196,7 +195,7 @@ func saveConfig(c *Config, engineName string) {
return
}

err = ioutil.WriteFile(fmt.Sprintf(configFile, getConfigDir(engineName), engineName), data, 0644)
err = os.WriteFile(fmt.Sprintf(configFile, getConfigDir(engineName), engineName), data, 0644)
if err != nil {
log.Println(err)
}
Expand Down