Skip to content

Commit

Permalink
remove deprecated io/ioutil (#48)
Browse files Browse the repository at this point in the history
* ioutil is deprecated since go 1.16
* go version in go.mod is 1.16, so removing won't affect us
  • Loading branch information
anoop142 committed Nov 9, 2023
1 parent 648da8a commit d97dcac
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions govarnam/govarnam_ml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package govarnam

import (
"context"
"io/ioutil"
"log"
"path"
"strings"
Expand Down Expand Up @@ -377,7 +376,7 @@ func TestMLExportAndImport(t *testing.T) {
varnam.Export(exportFileIntendedPath, 300)

// read the whole file at once
b, err := ioutil.ReadFile(exportFilePath)
b, err := os.ReadFile(exportFilePath)

Check failure on line 379 in govarnam/govarnam_ml_test.go

View workflow job for this annotation

GitHub Actions / build

undefined: os
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions govarnam/govarnam_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package govarnam

import (
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -104,7 +103,7 @@ func TestMain(m *testing.M) {
log.Fatal(err)
}

testTempDir, err = ioutil.TempDir("", "govarnam_test")
testTempDir, err = os.TempDir("", "govarnam_test")

Check failure on line 106 in govarnam/govarnam_test.go

View workflow job for this annotation

GitHub Actions / build

assignment mismatch: 2 variables but os.TempDir returns 1 values

Check failure on line 106 in govarnam/govarnam_test.go

View workflow job for this annotation

GitHub Actions / build

too many arguments in call to os.TempDir
checkError(err)

for _, schemeDetail := range schemeDetails {
Expand Down
5 changes: 2 additions & 3 deletions govarnam/learn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
sql "database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math"
"os"
Expand Down Expand Up @@ -624,7 +623,7 @@ func (varnam *Varnam) Export(filePath string, wordsPerFile int) error {
jsonData, err := json.Marshal(output)

filePathWithPageNumber := filePath + "-" + fmt.Sprint(page) + ".vlf"
err = ioutil.WriteFile(filePathWithPageNumber, jsonData, 0644)
err = os.WriteFile(filePathWithPageNumber, jsonData, 0644)
if err != nil {
return err
}
Expand All @@ -642,7 +641,7 @@ func (varnam *Varnam) Import(filePath string) error {
}

// TODO better reading of JSON. This loads entire file into memory
fileContent, _ := ioutil.ReadFile(filePath)
fileContent, _ := os.ReadFile(filePath)

var dbData exportFormat

Expand Down
3 changes: 1 addition & 2 deletions govarnamgo/govarnamgo_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package govarnamgo

import (
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -68,7 +67,7 @@ func tearDown() {

func TestMain(m *testing.M) {
var err error
testTempDir, err = ioutil.TempDir("", "govarnam_test")
testTempDir, err = os.TempDir("", "govarnam_test")
checkError(err)

setUp("ml")
Expand Down

0 comments on commit d97dcac

Please sign in to comment.