From 5d86baf17098c02ae72c34a0f268125c2e350e78 Mon Sep 17 00:00:00 2001 From: bense Date: Tue, 31 Jan 2023 08:49:16 +0800 Subject: [PATCH] update mod,readme file --- README.md | 4 ++-- client.go | 2 +- client_test.go | 2 +- examples/main.go | 31 +++++++++++++++++++++++++++++++ go.mod | 6 +++--- proto/get_security_list.go | 2 +- proto/get_security_quotes.go | 2 +- proto/hello1.go | 5 +++-- proto/hello2.go | 2 +- 9 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 examples/main.go diff --git a/README.md b/README.md index bf13638..fd1f097 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ package main import ( - "gotdx" + "github.com/bensema/gotdx" "log" ) @@ -28,7 +28,7 @@ func main() { } for _, obj := range reply.List { - log.Println(obj) + log.Printf("%+v", obj) } _ = api.Disconnect() diff --git a/client.go b/client.go index 968b624..c1977fd 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,7 @@ import ( "compress/zlib" "encoding/binary" "errors" - "gotdx/proto" + "github.com/bensema/gotdx/proto" "io" "log" "net" diff --git a/client_test.go b/client_test.go index d1a639d..d7975dd 100644 --- a/client_test.go +++ b/client_test.go @@ -2,7 +2,7 @@ package gotdx import ( "fmt" - "gotdx/proto" + "github.com/bensema/gotdx/proto" "testing" ) diff --git a/examples/main.go b/examples/main.go new file mode 100644 index 0000000..34cb02e --- /dev/null +++ b/examples/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "github.com/bensema/gotdx" + "log" +) + +func main() { + var opt = &gotdx.Opt{ + Host: "119.147.212.81", + Port: 7709, + } + api := gotdx.NewClient(opt) + connectReply, err := api.Connect() + if err != nil { + log.Println(err) + } + log.Println(connectReply.Info) + + reply, err := api.GetSecurityQuotes([]uint8{gotdx.MarketSh, gotdx.MarketSz}, []string{"000001", "600008"}) + if err != nil { + log.Println(err) + } + + for _, obj := range reply.List { + log.Printf("%+v", obj) + } + + _ = api.Disconnect() + +} diff --git a/go.mod b/go.mod index 70ff4d0..9629744 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module gotdx +module github.com/bensema/gotdx -go 1.18 +go 1.19 -require golang.org/x/text v0.3.7 +require golang.org/x/text v0.6.0 diff --git a/proto/get_security_list.go b/proto/get_security_list.go index b864321..2d97c5f 100644 --- a/proto/get_security_list.go +++ b/proto/get_security_list.go @@ -3,7 +3,7 @@ package proto import ( "bytes" "encoding/binary" - "gotdx/util" + "github.com/bensema/gotdx/util" ) type GetSecurityList struct { diff --git a/proto/get_security_quotes.go b/proto/get_security_quotes.go index c07841e..88d1236 100644 --- a/proto/get_security_quotes.go +++ b/proto/get_security_quotes.go @@ -5,7 +5,7 @@ import ( "encoding/binary" "encoding/hex" "fmt" - "gotdx/util" + "github.com/bensema/gotdx/util" ) type GetSecurityQuotes struct { diff --git a/proto/hello1.go b/proto/hello1.go index 9ebb426..efdc5f7 100644 --- a/proto/hello1.go +++ b/proto/hello1.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/binary" "encoding/hex" - "gotdx/util" + "github.com/bensema/gotdx/util" ) type Hello1 struct { @@ -54,7 +54,8 @@ func (obj *Hello1) Serialize() ([]byte, error) { /* 00e60708051 50 f0 00 d3 a02b2020c03840384038403840384033a02b2020c0384038403840384038403 00 5a8a3401 f94a0100 5a8a3401 fd4a0100ff00e 700000101013f - 分 时 秒 日期 + + 分 时 秒 日期 */ func (obj *Hello1) UnSerialize(header interface{}, data []byte) error { obj.respHeader = header.(*RespHeader) diff --git a/proto/hello2.go b/proto/hello2.go index 194ce96..4429052 100644 --- a/proto/hello2.go +++ b/proto/hello2.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/binary" "encoding/hex" - "gotdx/util" + "github.com/bensema/gotdx/util" ) type Hello2 struct {