Visitar URL original
Add Go examples to the learn pages by stellar-triage-bot[bot] · Pull Request #3125 · stellar/stellar-docs · GitHub
Skip to content

Add Go examples to the learn pages - #3125

Open
stellar-triage-bot[bot] wants to merge 2 commits into
docs-agent/1770-go-bfrom
docs-agent/1770-go-c
Open

stellar-triage-bot[bot] wants to merge 2 commits into
docs-agent/1770-go-bfrom
docs-agent/1770-go-c

Conversation

@stellar-triage-bot

Copy link
Copy Markdown
Contributor

🤖 Automated message from the Stellar Triage Bot.

Refs #1770

Working this because @ElliotFriend approved the Go and Java splits in #1770 and asked me to keep building the stack. This is Go C: Go tabs on the 8 learn/ pages. Base: #3124 (docs-agent/1770-go-b). Go D and Java A to D follow.

What changed

  • A Go tab next to every Stellar SDK example on these 8 pages under learn/fundamentals/:
    • stellar-data-structures/assets: tabs now in the order JavaScript, Python, Go, Java (Java moved after Python).
    • stellar-data-structures/events: the Go listener asks RPC for xdrFormat: "json", because the Go SDK has no scValToNative.
    • data-format/xdr: Go for the Uint64 primitive, the ScAddress union switch and ScAddress.String(). The Python Uint64 block moved into a code group with Go.
    • fees-resource-limits-metering: Go fee bump.
    • liquidity-on-stellar-sdex-liquidity-pools: all 6 code groups. Amounts stay in stroops (big.Rat, big.Int), and prices go through price.Parse.
    • contract-development/storage/state-archival: the same Go code as the reviewed archival guides in Add Go examples to the archival, conventions, rpc, conversions and events guides #3124.
    • contract-development/contract-interactions/transaction-simulation: all 3 examples.
    • contract-development/contract-interactions/stellar-transaction: a Go tab in <Tabs>, between Python and Java.
  • Every transaction bids the capped fee-stats p90, like the other tabs.
  • The Go SDK has no prepareTransaction and no auth-entry signer. Where a page needs one, the Go tab defines a small helper and says so in a comment.
  • Prose changed only where it named JavaScript and Python alone, or where it named a JavaScript or Python helper with no Go match (xdr, state-archival).

Why this matters

Go readers had no example on these 8 pages. @ElliotFriend chose all four languages on every page in #1770.

Sweep

Not a claim fix, so no sweep. I checked the prose next to each new tab for text that named only JavaScript or Python, and updated it.

Verified

  • Every Go symbol, field and type against go-stellar-sdk v0.9.0, the newest release (2026-11-12). The pages pin no Go SDK version.
    • txnbuild: transaction.go (NewTransaction, NewFeeBumpTransaction, FeeBumpTransactionParams; BaseFee() returns the bid without the resource fee, L220, L829), asset.go, change_trust.go, change_trust_asset.go, liquidity_pool_{deposit,withdraw,id,parameters}.go, payment.go.
    • clients/horizonclient: client.go (FeeStats, AccountDetail, LiquidityPoolDetail, Operations, SubmitTransaction, SubmitFeeBumpTransaction), main.go, liquidity_pool_request.go.
    • protocols/horizon: Balance, LiquidityPool, LiquidityPoolReserve, FeeDistribution.P90 (int64). operations/main.go unmarshals a deposit as the value type LiquidityPoolDeposit (L629-634).
    • clients/rpcclient/main.go: PollTransaction polls until its context ends (L242-294), so the Go tab sets a 30-second deadline and reports "status unknown" when it passes.
    • protocols/rpc: get_events.go (a cursor and a start ledger cannot both be set, L168-174), cursor.go (ParseCursor), format.go (FormatJSON), simulate_transaction.go, send_transaction.go, get_transaction.go.
    • xdr: xdr_generated.go (ScAddress arms, SorobanCredentialsTypeSorobanCredentialsAddressV2, HashIdPreimageSorobanAuthorizationWithAddress, Uint64), scval.go (ScAddress.String), asset.go (Asset.ContractID), main.go (MarshalBase64).
    • price/main.go (Parse), amount/main.go (ParseInt64, StringFromInt64), keypair/main.go (MustParseFull, MustRandom), strkey/main.go (MustEncode).
  • Testnet runs Protocol 30 (Horizon testnet ledger 5705894). So the Go authorizeEntry on transaction-simulation signs both legacy and V2 address credentials, like the JavaScript and Python tabs there. V2 signs the ENVELOPE_TYPE_SOROBAN_AUTHORIZATION_WITH_ADDRESS preimage, which also holds the address, the same as py-stellar-base 17.0.1 stellar_sdk/auth.py build_authorization_preimage.
  • pnpm check passes: prettier, mint validate, no broken links.

Not verified

Overlaps

Found in passing, not fixed here

#3119 collects defects in existing code, but it carries bot:hands-off, so I did not post there. A maintainer can move these to it.

  1. liquidity-on-stellar-sdex-liquidity-pools.mdx (prose under the preamble): it says the two funded accounts are kp2 and kp3. The code names them kps[1] and kps[2] (kp1 and kp2).
  2. Same page, JavaScript main(): it deposits from all three keypairs, the issuer kp0 too. Python, and now Go, deposit from kp1 and kp2 only.
  3. stellar-transaction.mdx: the JavaScript and Java tabs call contract CBEOJUP5…KZW6, the Python tab CDMARRPK…5U73. The Go tab uses the JavaScript one.
  4. Go A (Add Go examples to the transactions and basics guides #3123) signing-soroban-invocations.mdx: its Go authorizeEntry signs only legacy address credentials. Testnet runs Protocol 30, so simulation can return V2 entries that it skips. This PR's transaction-simulation Go tab handles both. I can port that to Add Go examples to the transactions and basics guides #3123 if you want it there.

Go tabs on the 8 learn/ pages that had JavaScript, Python or Java examples but no Go: assets, events, XDR, fees, liquidity pools, state archival, transaction simulation and the Stellar transaction page.
@stellar-triage-bot stellar-triage-bot Bot added the bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge label Nov 13, 2026
@stellar-triage-bot

Copy link
Copy Markdown
Contributor Author

🤖 Automated message from the Stellar Triage Bot.

Reviewing because I opened this PR for #1770.

Verified: every Go symbol matches go-stellar-sdk v0.9.0, and checks passes. Ready to merge after #3115, #3123 and #3124.
Not run: all Go blocks on the 8 pages. Please compile them before merge.

What I checked
  • Checked against go-stellar-sdk v0.9.0 (newest, 2026-11-12). The pages pin no Go SDK version.
  • Pushed a4e5cc0: xdr.mdx:70 said "Other languages have no such variations". java-stellar-sdk 6.0.0 wraps xdr.Uint64 in XdrUnsignedHyperInteger(BigInteger | Long), so it now says "Python and Go".
  • Example 2 sets operation.Auth after the build. That works because NewTransaction keeps the operation pointers (txnbuild/transaction.go:834).
  • assembleTransaction reuses tx.BaseFee(), which is the bid without the resource fee (transaction.go:220, :909-921).
  • PollTransaction uses backoff v4.3.0 with no elapsed-time cap, so the 30 s context deadline surfaces as context.DeadlineExceeded (clients/rpcclient/main.go:249-294).
  • V2 auth signing matches py-stellar-base 17.0.1 stellar_sdk/auth.py:110-166. Testnet runs Protocol 30 (Horizon ledger 5706180).
  • Horizon types: operations/main.go:629-631 decodes a deposit as the value type LiquidityPoolDeposit. Balance embeds base.Asset (Type) and has LiquidityPoolId.
  • The state-archival Go tabs use submitTx and server from the Go tab on submit-transaction-wait.mdx (base branch).
  • Tab order is JavaScript, Python, Go, Java in every touched code group.
  • CI at a4e5cc0: checks, CodeQL and Socket pass, with no broken links. Mintlify Deployment skipped because the base is not main, so no live preview was available.
  • Outside this PR: Add Go examples to the transactions and basics guides #3123 signing-soroban-invocations.mdx:678 has a Go authorizeEntry that signs only legacy address credentials. It skips the V2 entries that Protocol 30 simulation can return.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants