Skip to content

Commit

Permalink
token info by scraping: decimals regex fix (#82)
Browse files Browse the repository at this point in the history
* token info by scraping: decimals regex fix

* lint fixes
  • Loading branch information
nikoskarakostas authored Dec 13, 2022
1 parent 652b882 commit b57f362
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
12 changes: 6 additions & 6 deletions file/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
)

const (
fileModeReadWrite = 0600 // nolint
fileModeReadWrite = 0600 //nolint
indent = " "
prefix = ""
)
Expand All @@ -29,7 +29,7 @@ func PrepareJSONData(payload interface{}) ([]byte, error) {
}

func CreateJSONFile(path string, data []byte) error {
err := ioutil.WriteFile(path, data, fileModeReadWrite)
err := os.WriteFile(path, data, fileModeReadWrite)
if err != nil {
return fmt.Errorf("failed to write json to file: %w", err)
}
Expand All @@ -44,7 +44,7 @@ func ReadJSONFile(path string, result interface{}) error {
}
defer file.Close()

data, err := ioutil.ReadAll(file)
data, err := io.ReadAll(file)
if err != nil {
return fmt.Errorf("failed to read data from file: %w", err)
}
Expand All @@ -64,7 +64,7 @@ func FormatJSONFile(path string) error {
}
defer file.Close()

data, err := ioutil.ReadAll(file)
data, err := io.ReadAll(file)
if err != nil {
return fmt.Errorf("failed to read data from file: %w", err)
}
Expand All @@ -76,7 +76,7 @@ func FormatJSONFile(path string) error {
return fmt.Errorf("failed to indent json: %w", err)
}

err = ioutil.WriteFile(path, prettyJSON.Bytes(), fileModeReadWrite)
err = os.WriteFile(path, prettyJSON.Bytes(), fileModeReadWrite)
if err != nil {
return fmt.Errorf("failed to write json to file: %w", err)
}
Expand Down
7 changes: 3 additions & 4 deletions http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package http
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -21,9 +21,8 @@ func GetHTTPResponse(url string, result interface{}) error {
return nil
}

// nolint
func GetHTTPResponseBytes(url string) ([]byte, error) {
resp, err := http.Get(url)
resp, err := http.Get(url) //nolint
if err != nil {
return nil, fmt.Errorf("failed to make GET request: %w", err)
}
Expand All @@ -33,7 +32,7 @@ func GetHTTPResponseBytes(url string) ([]byte, error) {
return nil, fmt.Errorf("unsuccessful status code: %d", resp.StatusCode)
}

bodyBytes, err := ioutil.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read body: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion validation/info/external/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var (
holdersRegexp = regexp.MustCompile(`(\d+)\saddresses`)
decimalsRegexp = regexp.MustCompile(`(\d+)\s<\/div>`)
decimalsRegexp = regexp.MustCompile(`(\d+)\s+<\/div>`)
symbolRegexp = regexp.MustCompile(`<b>(\w+)<\/b>\s<span`)
)

Expand Down
2 changes: 1 addition & 1 deletion validation/info/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/trustwallet/go-primitives/coin"
)

// nolint:gochecknoglobals
//nolint:gochecknoglobals
var (
requiredCoinFields = []string{
"name", "type", "symbol", "decimals",
Expand Down

0 comments on commit b57f362

Please sign in to comment.