HuobiRDCenter / huobi_Golang

Go SDK for Huobi Spot API
https://www.htx.com/zh-cn/opend/newApiPages/
Apache License 2.0
176 stars 86 forks source link

cannot find package "." in: github.com/huobirdcenter/huobi_golang/pkg/client/orderwebsocketclient #40

Closed TuringZhu closed 3 years ago

TuringZhu commented 3 years ago

build failed with can not find package "."

go version && huobi_golang version

go version go1.16 darwin/amd64

github.com/huobirdcenter/huobi_golang v0.0.0-20201119082032-67bf5220fbce

example code:

package main

import (
    "github.com/huobirdcenter/huobi_golang/config"
    "github.com/huobirdcenter/huobi_golang/logging/applogger"
    "github.com/huobirdcenter/huobi_golang/pkg/client/orderwebsocketclient"
    "github.com/huobirdcenter/huobi_golang/pkg/model/auth"
    "github.com/huobirdcenter/huobi_golang/pkg/model/order"
)

func main() {
    // Initialize a new instance
    client := new(orderwebsocketclient.SubscribeOrderWebSocketV2Client).Init(config.AccessKey, config.AccountId, config.Host)

    // Set the callback handlers
    client.SetHandler(
        // Connected handler
        func(resp *auth.WebSocketV2AuthenticationResponse) {
            if resp.IsSuccess() {
                // Subscribe if authentication passed
                client.Subscribe("btcusdt", "1149")
            } else {
                applogger.Info("Authentication error, code: %d, message:%s", resp.Code, resp.Message)
            }
        },
        // Response handler
        func(resp interface{}) {
            subResponse, ok := resp.(order.SubscribeOrderV2Response)
            if ok {
                if subResponse.Action == "sub" {
                    if subResponse.IsSuccess() {
                        applogger.Info("Subscription topic %s successfully", subResponse.Ch)
                    } else {
                        applogger.Error("Subscription topic %s error, code: %d, message: %s", subResponse.Ch, subResponse.Code, subResponse.Message)
                    }
                } else if subResponse.Action == "push" {
                    if subResponse.Data != nil {
                        o := subResponse.Data
                        applogger.Info("Order update, event: %s, symbol: %s, type: %s, status: %s",
                            o.EventType, o.Symbol, o.Type, o.OrderStatus)
                    }
                }
            } else {
                applogger.Warn("Received unknown response: %v", resp)
            }
        })

    // Connect to the server and wait for the handler to handle the response
    client.Connect(true)}

error info:

cannot find package "." in:

/MY_PROJECT_PATH/vendor/github.com/huobirdcenter/huobi_golang/pkg/client/orderwebsocketclient
TuringZhu commented 3 years ago

I build with go mod. After I delete vendor directory, it worked.