Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
fix url data
Browse files Browse the repository at this point in the history
  • Loading branch information
m1 committed Jan 13, 2020
1 parent 84f5bb8 commit 459dd8c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 3 additions & 5 deletions company.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ func (c *Company) UnmarshalJSON(data []byte) error {
if err = json.Unmarshal(data, &company); err != nil {
return err
}
if company.WebURL != "" {
c.WebURL, err = url.Parse(company.WebURL)
if err != nil {
return err
}
c.WebURL, err = url.Parse(company.WebURL)
if err != nil {
return err
}
return err
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/m1/go-finnhub

go 1.13

require github.com/stretchr/testify v1.4.0
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
4 changes: 0 additions & 4 deletions news.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ func (n *News) UnmarshalJSON(data []byte) error {
return err
}
n.DateTime = time.Unix(news.DateTime, 0)
if news.Image != "" {
n.Image, err = url.Parse(news.Image)

if err != nil {
return err
}
}
if news.URL != "" {
n.URL, err = url.Parse(news.URL)
if err != nil {
return err
}
}
return nil
}

0 comments on commit 459dd8c

Please sign in to comment.