adshao / go-binance

A Go SDK for Binance API
MIT License
1.54k stars 677 forks source link

Basic code example #432

Closed vulnz closed 3 months ago

vulnz commented 1 year ago

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()

`

adshao commented 1 year ago

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.