### Initialize SDK and Get Global State Source: https://github.com/hyperjiang/futu/blob/main/README.md Demonstrates how to initialize the Futu SDK and retrieve the global state. Errors during initialization will be logged. ```go import "github.com/hyperjiang/futu" func main() { sdk, err := futu.NewSDK() if err != nil { log.Fatal(err) } res, err := sdk.GetGlobalState() fmt.Println(res) } ``` -------------------------------- ### Run Single Test Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Execute a specific test case, for example, 'TestNewSecurity'. ```bash go test -run TestNewSecurity ``` -------------------------------- ### SDK Architecture Overview Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Illustrates the three-layer design of the Futu Go SDK, separating user-facing logic, low-level client operations, and the FutuOpenD gateway. ```text Root package (futu/) ← User-facing SDK, friendly types, 5s default timeout ↓ delegates to client/ ← Low-level protobuf client, raw C2S/S2C structs ↓ communicates with FutuOpenD (TCP:11111) ← Binary protocol: 'FT' header + protobuf body + AES-CBC encryption ``` -------------------------------- ### Using Options Pattern for API Parameters Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Demonstrates how to use the adapt.With() functional options to pass optional parameters to SDK methods. These options are internally managed as a map and serialized to protobuf via JSON. ```go sdk.GetKL("HK.09988", adapt.KLType_Day, adapt.With("rehabType", adapt.RehabType_Forward), adapt.With("reqNum", 3), ) ``` -------------------------------- ### Static Analysis Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Perform static analysis on the entire project using the 'go vet' tool. ```bash go vet ./... ``` -------------------------------- ### Run All Tests Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Execute all tests in the project. Requires FutuOpenD running locally. ```bash go test ./... ``` -------------------------------- ### Run Unit Tests (Adapt Package) Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Execute only the unit tests within the adapt package. These tests do not require external dependencies. ```bash go test ./adapt/... ``` -------------------------------- ### Data Flow: SDK to FutuOpenD Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Details the process of how SDK methods convert user-friendly types into protobuf requests, encrypt them, and send them to FutuOpenD. ```text 1. SDK method builds `adapt.Options` map → converts to protobuf C2S via `json.Marshal`/`json.Unmarshal` (`adapt/option.go:88`) 2. Client wraps C2S in a `Request` proto, encrypts body (RSA for InitConnect, AES-CBC for all else), writes binary header + body to TCP conn 3. Response read loop (`infiniteRead`) decodes header, decrypts, dispatches to registered channel via `DispatcherHub` keyed on `(protoID, serialNo)` 4. Push notifications use `serialNo = 0` and are routed to handler functions registered via `RegisterHandler` ``` -------------------------------- ### Run Unit Tests (Infra Package) Source: https://github.com/hyperjiang/futu/blob/main/AGENTS.md Execute only the unit tests within the infra package. These tests do not require external dependencies. ```bash go test ./infra/... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.