go-binance icon indicating copy to clipboard operation
go-binance copied to clipboard

Basic code example

Open vulnz opened this issue 2 years ago • 1 comments

Good day, followed the guide, however having this issue:

Please clarify on how to run basic command using your library. Execution is not even getting to level of main function execution.

go run test.go test.go:3:5: found packages binance (account_service.go) and main (test.go) in C:\Users\name\Downloads\go-binance-master\go-binance-master\v2

package main
import (
    "github.com/adshao/go-binance/v2"
    "fmt"
)



func main(){
  fmt.Println("123")
  var (
      apiKey = "XX"
      secretKey = "xxx"
  )


  order, err := client.NewCreateOrderService().Symbol("BNBETH").
          Side(binance.SideTypeBuy).Type(binance.OrderTypeLimit).
          TimeInForce(binance.TimeInForceTypeGTC).Quantity("5").
          Price("0.0030000").Do(context.Background())
  if err != nil {
      fmt.Println(err)
      return
  }
  fmt.Println(order)

  do()
}


main()
```
`

vulnz avatar Oct 22 '22 23:10 vulnz

Good day, followed the guide, however having this issue:

Please clarify on how to run basic command using your library. Execution is not even getting to level of main function execution.

go run test.go test.go:3:5: found packages binance (account_service.go) and main (test.go) in C:\Users\name\Downloads\go-binance-master\go-binance-master\v2

package main
import (
    "github.com/adshao/go-binance/v2"
    "fmt"
)



func main(){
  fmt.Println("123")
  var (
      apiKey = "XX"
      secretKey = "xxx"
  )


  order, err := client.NewCreateOrderService().Symbol("BNBETH").
          Side(binance.SideTypeBuy).Type(binance.OrderTypeLimit).
          TimeInForce(binance.TimeInForceTypeGTC).Quantity("5").
          Price("0.0030000").Do(context.Background())
  if err != nil {
      fmt.Println(err)
      return
  }
  fmt.Println(order)

  do()
}


main()

`

As the error said, your should use package main instead of binance in your code.

adshao avatar Nov 21 '22 14:11 adshao