[{"data":1,"prerenderedAt":472},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fsdks\u002Fgo":3},{"id":4,"title":5,"body":6,"description":465,"extension":466,"meta":467,"navigation":84,"path":468,"seo":469,"stem":470,"__hash__":471},"content\u002Fdocs\u002Fsdks\u002Fgo.md","Go SDK",{"type":7,"value":8,"toc":457},"minimark",[9,13,34,39,64,68,272,276,279,346,358,362,422,426,435,439,453],[10,11,5],"h1",{"id":12},"go-sdk",[14,15,16,17,21,22,25,26,29,30,33],"p",{},"The Go SDK is a single module — ",[18,19,20],"code",{},"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo"," — with module-specific sub-packages under ",[18,23,24],{},"sdk\u002Fgo\u002Fmodules\u002F",". It uses standard ",[18,27,28],{},"context.Context",", has no third-party dependencies, and works with any transport that implements the ",[18,31,32],{},"Transport"," interface (USB-serial provided; bring your own for BLE \u002F TCP \u002F etc.).",[35,36,38],"h2",{"id":37},"install","Install",[40,41,46],"pre",{"className":42,"code":43,"language":44,"meta":45,"style":45},"language-bash shiki shiki-themes github-light github-dark","go get github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo@latest\n","bash","",[18,47,48],{"__ignoreMap":45},[49,50,53,57,61],"span",{"class":51,"line":52},"line",1,[49,54,56],{"class":55},"sScJk","go",[49,58,60],{"class":59},"sZZnC"," get",[49,62,63],{"class":59}," github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo@latest\n",[35,65,67],{"id":66},"quick-start","Quick start",[40,69,72],{"className":70,"code":71,"language":56,"meta":45,"style":45},"language-go shiki shiki-themes github-light github-dark","package main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"time\"\n\n    conduyt \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Ftransports\"\n)\n\nfunc main() {\n    transport, err := transports.NewSerial(\"\u002Fdev\u002Fcu.usbmodem14101\", 115200)\n    if err != nil {\n        log.Fatal(err)\n    }\n    device := conduyt.NewDevice(transport, 5*time.Second)\n\n    ctx := context.Background()\n    hello, err := device.Connect(ctx)\n    if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(\"connected to\", hello.FirmwareName)\n\n    if err := device.PinMode(ctx, 13, conduyt.PinModeOutput); err != nil {\n        log.Fatal(err)\n    }\n    if err := device.PinWrite(ctx, 13, 1); err != nil {\n        log.Fatal(err)\n    }\n\n    _ = device.Close()\n}\n",[18,73,74,79,86,92,98,104,110,116,121,127,133,139,144,150,156,162,168,174,180,185,191,197,202,207,212,218,223,229,234,239,245,250,255,260,266],{"__ignoreMap":45},[49,75,76],{"class":51,"line":52},[49,77,78],{},"package main\n",[49,80,82],{"class":51,"line":81},2,[49,83,85],{"emptyLinePlaceholder":84},true,"\n",[49,87,89],{"class":51,"line":88},3,[49,90,91],{},"import (\n",[49,93,95],{"class":51,"line":94},4,[49,96,97],{},"    \"context\"\n",[49,99,101],{"class":51,"line":100},5,[49,102,103],{},"    \"fmt\"\n",[49,105,107],{"class":51,"line":106},6,[49,108,109],{},"    \"log\"\n",[49,111,113],{"class":51,"line":112},7,[49,114,115],{},"    \"time\"\n",[49,117,119],{"class":51,"line":118},8,[49,120,85],{"emptyLinePlaceholder":84},[49,122,124],{"class":51,"line":123},9,[49,125,126],{},"    conduyt \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\"\n",[49,128,130],{"class":51,"line":129},10,[49,131,132],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Ftransports\"\n",[49,134,136],{"class":51,"line":135},11,[49,137,138],{},")\n",[49,140,142],{"class":51,"line":141},12,[49,143,85],{"emptyLinePlaceholder":84},[49,145,147],{"class":51,"line":146},13,[49,148,149],{},"func main() {\n",[49,151,153],{"class":51,"line":152},14,[49,154,155],{},"    transport, err := transports.NewSerial(\"\u002Fdev\u002Fcu.usbmodem14101\", 115200)\n",[49,157,159],{"class":51,"line":158},15,[49,160,161],{},"    if err != nil {\n",[49,163,165],{"class":51,"line":164},16,[49,166,167],{},"        log.Fatal(err)\n",[49,169,171],{"class":51,"line":170},17,[49,172,173],{},"    }\n",[49,175,177],{"class":51,"line":176},18,[49,178,179],{},"    device := conduyt.NewDevice(transport, 5*time.Second)\n",[49,181,183],{"class":51,"line":182},19,[49,184,85],{"emptyLinePlaceholder":84},[49,186,188],{"class":51,"line":187},20,[49,189,190],{},"    ctx := context.Background()\n",[49,192,194],{"class":51,"line":193},21,[49,195,196],{},"    hello, err := device.Connect(ctx)\n",[49,198,200],{"class":51,"line":199},22,[49,201,161],{},[49,203,205],{"class":51,"line":204},23,[49,206,167],{},[49,208,210],{"class":51,"line":209},24,[49,211,173],{},[49,213,215],{"class":51,"line":214},25,[49,216,217],{},"    fmt.Println(\"connected to\", hello.FirmwareName)\n",[49,219,221],{"class":51,"line":220},26,[49,222,85],{"emptyLinePlaceholder":84},[49,224,226],{"class":51,"line":225},27,[49,227,228],{},"    if err := device.PinMode(ctx, 13, conduyt.PinModeOutput); err != nil {\n",[49,230,232],{"class":51,"line":231},28,[49,233,167],{},[49,235,237],{"class":51,"line":236},29,[49,238,173],{},[49,240,242],{"class":51,"line":241},30,[49,243,244],{},"    if err := device.PinWrite(ctx, 13, 1); err != nil {\n",[49,246,248],{"class":51,"line":247},31,[49,249,167],{},[49,251,253],{"class":51,"line":252},32,[49,254,173],{},[49,256,258],{"class":51,"line":257},33,[49,259,85],{"emptyLinePlaceholder":84},[49,261,263],{"class":51,"line":262},34,[49,264,265],{},"    _ = device.Close()\n",[49,267,269],{"class":51,"line":268},35,[49,270,271],{},"}\n",[35,273,275],{"id":274},"modules","Modules",[14,277,278],{},"Each module is a sub-package. Import what you need:",[40,280,282],{"className":70,"code":281,"language":56,"meta":45,"style":45},"import (\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fservo\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fneopixel\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Foled\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fdht\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fencoder\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fstepper\"\n    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fpid\"\n)\n\ns := servo.New(device, 0)   \u002F\u002F moduleID = 0 (resolve from HELLO_RESP)\nif err := s.Attach(ctx, 9, 1000, 2000); err != nil { log.Fatal(err) }\nif err := s.Write(ctx, 90); err != nil { log.Fatal(err) }\n",[18,283,284,288,293,298,303,308,313,318,323,327,331,336,341],{"__ignoreMap":45},[49,285,286],{"class":51,"line":52},[49,287,91],{},[49,289,290],{"class":51,"line":81},[49,291,292],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fservo\"\n",[49,294,295],{"class":51,"line":88},[49,296,297],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fneopixel\"\n",[49,299,300],{"class":51,"line":94},[49,301,302],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Foled\"\n",[49,304,305],{"class":51,"line":100},[49,306,307],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fdht\"\n",[49,309,310],{"class":51,"line":106},[49,311,312],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fencoder\"\n",[49,314,315],{"class":51,"line":112},[49,316,317],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fstepper\"\n",[49,319,320],{"class":51,"line":118},[49,321,322],{},"    \"github.com\u002Fvirgilvox\u002Fconduyt\u002Fsdk\u002Fgo\u002Fmodules\u002Fpid\"\n",[49,324,325],{"class":51,"line":123},[49,326,138],{},[49,328,329],{"class":51,"line":129},[49,330,85],{"emptyLinePlaceholder":84},[49,332,333],{"class":51,"line":135},[49,334,335],{},"s := servo.New(device, 0)   \u002F\u002F moduleID = 0 (resolve from HELLO_RESP)\n",[49,337,338],{"class":51,"line":141},[49,339,340],{},"if err := s.Attach(ctx, 9, 1000, 2000); err != nil { log.Fatal(err) }\n",[49,342,343],{"class":51,"line":146},[49,344,345],{},"if err := s.Write(ctx, 90); err != nil { log.Fatal(err) }\n",[14,347,348,349,352,353,357],{},"Look up the module ID from ",[18,350,351],{},"device.Capabilities().Modules"," to avoid hard-coding it. See the per-module pages under ",[354,355,275],"a",{"href":356},"\u002Fdocs\u002Fmodules\u002Fservo"," for command reference.",[35,359,361],{"id":360},"transports","Transports",[363,364,365,380],"table",{},[366,367,368],"thead",{},[369,370,371,374,377],"tr",{},[372,373,32],"th",{},[372,375,376],{},"Package",[372,378,379],{},"Notes",[381,382,383,401],"tbody",{},[369,384,385,389,394],{},[386,387,388],"td",{},"Serial",[386,390,391],{},[18,392,393],{},"transports.NewSerial(path, baud)",[386,395,396,397,400],{},"Pure-Go USB-serial via ",[18,398,399],{},"go.bug.st\u002Fserial"," (vendored)",[369,402,403,406,411],{},[386,404,405],{},"Mock",[386,407,408],{},[18,409,410],{},"transports.NewMock()",[386,412,413,414,417,418,421],{},"In-memory, captures ",[18,415,416],{},"SentPackets",", lets you ",[18,419,420],{},"Inject"," responses",[35,423,425],{"id":424},"concurrency","Concurrency",[14,427,428,431,432,434],{},[18,429,430],{},"*conduyt.Device"," is safe to share across goroutines for sending commands. Each method takes a ",[18,433,28],{}," so you can cancel or timeout per-call. Internally there's a single sequence-number counter under a mutex.",[35,436,438],{"id":437},"versioning","Versioning",[14,440,441,444,445,448,449,452],{},[18,442,443],{},"conduyt-go"," is versioned by git tag (",[18,446,447],{},"v1.0.0",", etc.). It requires firmware running protocol version 2. The version byte is exported as ",[18,450,451],{},"conduyt.ProtocolVersion",".",[454,455,456],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":45,"searchDepth":81,"depth":81,"links":458},[459,460,461,462,463,464],{"id":37,"depth":81,"text":38},{"id":66,"depth":81,"text":67},{"id":274,"depth":81,"text":275},{"id":360,"depth":81,"text":361},{"id":424,"depth":81,"text":425},{"id":437,"depth":81,"text":438},"Idiomatic Go client for CONDUYT — context-aware, no third-party deps, with module sub-packages.","md",{},"\u002Fdocs\u002Fsdks\u002Fgo",{"title":5,"description":465},"docs\u002Fsdks\u002Fgo","_aP7iPOPKcFYDvz0SCx7Q3TISCsKIDoGcOQE6mi2QMM",1777412315732]