Skip to content

Commit

Permalink
Replace io/ioutil to os based on new Go standard
Browse files Browse the repository at this point in the history
  • Loading branch information
goatastronaut0212 committed May 11, 2024
1 parent 615e5cc commit bb958ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
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

0 comments on commit bb958ad

Please sign in to comment.