Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually return an error for unknown symbol #22

Merged
merged 1 commit into from
May 8, 2023

Conversation

pallotron
Copy link
Contributor

@pallotron pallotron commented Jan 23, 2022

quote.Get of an inexistent symbol should return a non nil error.
This does not happen....
To repro ask for a quote from a un-existant symbol:

package main

import (
  "fmt"

  "github.com/piquette/finance-go/quote"
)

func main() {
  q, err := quote.Get("FOOAASDADSAS") // <---- panic here because both `q` and `err` are `nil` 
  if err != nil {
    panic(err)
  }
  fmt.Printf("RegulardMarketPrice: %# +v", q.RegularMarketPrice)
}

This will panic:

$ go run .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x620b2e]

goroutine 1 [running]:
main.main()
        /home/pallotron/projects/example/ticker-quote.go:14 +0x2e
exit status 2
[Exit code 1 @ 10:12:01]

get.Quote should return an error in this case.

`quote.Get` of an inexistent symbol should return a non nil error.
This does not happen....
To repro ask for a quote from a un-existant symbol:

```golang
package main

import (
  "fmt"

  "github.com/piquette/finance-go/quote"
)

func main() {
  q, err := quote.Get("FOOAASDADSAS")
  if err != nil {
    panic(err)
  }
  fmt.Printf("RegulardMarketPrice: %# +v", q.RegularMarketPrice)
}

```

This will panic:

```
$ go run .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x620b2e]

goroutine 1 [running]:
main.main()
        /home/pallotron/projects/example/ticker-quote.go:14 +0x2e
exit status 2
[Exit code 1 @ 10:12:01]
```

`get.Quote` should return an error in this case.
@pallotron
Copy link
Contributor Author

Hello? Can you review this please? :)

@pallotron
Copy link
Contributor Author

@ackleymi, @jacks821 @pkaeding can you guys please stamp this?

@CMiksche
Copy link

CMiksche commented Jun 4, 2022

@ackleymi Could you merge this? This is the only error I encounter with this library so far and I think many people would be happy if they don't get a panic and a error instead.

@pallotron
Copy link
Contributor Author

this project is very active :D

@ktpx
Copy link

ktpx commented Oct 5, 2022

this project is very active :D

Seems abandoned.

@sunglim
Copy link

sunglim commented Apr 20, 2023

Is there any forks maintained?

@sunglim
Copy link

sunglim commented Apr 20, 2023

@pallotron Please feel free to bring this change to my fork, https://github.com/sunglim/yh-finance-go

@ackleymi ackleymi merged commit c2477f7 into piquette:master May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants