'Golang - How to format GetTicker response to Luno API correctly?
I used the code example from this link https://github.com/luno/luno-go/blob/master/api.go I used the ticker request portion and am trying to format the response to the fields. eg log.Println("Ask: ", askPrice)
ctx := context.Background()
{
req := luno.GetTickerRequest{Pair: "XBTZAR"}
res, err := cl.GetTicker(ctx, &req)
if err != nil {
log.Println(err)
}
log.Printf("%+v", res)
askPrice := res.Ask
log.Println("Ask:", askPrice)
time.Sleep(500 * time.Millisecond)
}
OUTPUT FOR log.Printf("%+v", res)
2022/03/22 06:56:39 &{Ask:657143.00000000 Bid:657071.00000000 LastTrade:657073.00000000 Pair:XBTZAR Rolling24HourVolume:181.37190600 Status:ACTIVE Timestamp:2022-03-22 06:56:34.98 +0200 SAST}
OUTPUT FOR log.Println("Ask:", askPrice)
2022/03/22 06:33:59 Ask: 658256.00000000
EXPECTED
Ask: 658256.00000000
Solution 1:[1]
Dont use log.PrintXXX, use fmt package
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tiago Peczenyj |