Skip to content

Commit

Permalink
misc : try to load file directly with it's name
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinToubi committed Jun 13, 2023
1 parent 8bf8c11 commit c6afa95
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions countries.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)

type CountryData struct {
Expand All @@ -22,22 +20,16 @@ type Country struct {

func InstanceCountry() *CountryData {
instance := &CountryData{}
instance = instance.readCountriesFile()
instance = instance.ReadCountriesFile()

return instance
}

func (data *CountryData) readCountriesFile() *CountryData {
func (data *CountryData) ReadCountriesFile() *CountryData {
if len(data.countries) > 0 {
return data
}
path := os.Getenv("GOPATH") + "/src/github.com/RobinToubi/countries/countries.json"
filePath, err := filepath.Abs(path)
if err != nil {
fmt.Println(err)
return nil
}
file, err := ioutil.ReadFile(filePath)
file, err := ioutil.ReadFile("countries.json")
if err != nil {
return nil
}
Expand Down

0 comments on commit c6afa95

Please sign in to comment.