Skip to content

Add Go examples to the learn pages - #3125

Merged
ElliotFriend merged 3 commits into
docs-agent/1770-go-bfrom
docs-agent/1770-go-c
Nov 13, 2026
Merged

ElliotFriend merged 3 commits into
docs-agent/1770-go-bfrom
docs-agent/1770-go-c

Conversation

@stellar-doxie

@stellar-doxie stellar-doxie Bot commented Nov 13, 2026 •

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.
  • @ElliotFriend compiled every Go block against go-stellar-sdk v0.9.0, ran go vet, and ran them on testnet (review on a4e5cc0). The later commit changes only prose and code comments.
  • CI (checks, CodeQL, Socket) passes at the current head.

Not verified

  • Nothing open. The bot lane did not run the Go code itself; @ElliotFriend's run covers it.

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.

@stellar-doxie
stellar-doxie Bot added this pull request to stack #3118 November 13, 2026 07:05
@stellar-doxie stellar-doxie Bot added the bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge label Nov 13, 2026
@stellar-doxie

stellar-doxie Bot commented Nov 13, 2026

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.

@ElliotFriend ElliotFriend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every Go block compiles against go-stellar-sdk v0.9.0, passes go vet, and ran on testnet. No code changes needed. Small prose fixes before merge:

  • Oxford comma: stellar-transaction.mdx:10; events.mdx:190; xdr.mdx:154; transaction-simulation.mdx:547; liquidity-on-stellar-sdex-liquidity-pools.mdx:321; and the prepareTransaction/assembleTransaction doc comments ("resources, resource fee and authorization entries").
  • xdr.mdx:174: "Stellar Network" should be "Stellar network" (CONTRIBUTING terminology).
  • stellar-transaction.mdx:10: since this line changes anyway, make the increment example link root-relative (/docs/build/smart-contracts/getting-started/storing-data).

The increment contract at stellar-transaction.mdx:246 no longer exists on testnet. That affects every tab, and a separate PR covers it, so leave it out of this one.

@stellar-doxie

stellar-doxie Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Automated message from the Stellar Triage Bot.

Back on this because @ElliotFriend requested changes.

Done in b22b3b5: every prose fix from your review. checks, CodeQL and Socket pass. Ready to merge after #3115, #3123 and #3124. Your changes-requested review still needs clearing.

What I checked
  • Oxford comma: stellar-transaction.mdx:10, events.mdx:190, xdr.mdx:154, transaction-simulation.mdx:547, liquidity-on-stellar-sdex-liquidity-pools.mdx:321, and the helper doc comments in stellar-transaction.mdx and state-archival.mdx.
  • xdr.mdx:174: "Stellar network" (CONTRIBUTING.md:109).
  • stellar-transaction.mdx:10: the increment link is now /docs/build/smart-contracts/getting-started/storing-data. That page exists.
  • Added one comment line above the two type assertions that panic on another operation type (stellar-transaction.mdx, state-archival.mdx). This matches what Add Go examples to the archival, conventions, rpc, conversions and events guides #3124 did after your review there. No code change.
  • I searched every line this PR adds for a list of three or more with no Oxford comma. None is left.
  • Left out, as you asked: the increment contract that is gone from testnet.
  • Base docs-agent/1770-go-b has a newer commit (64bf325). It merges cleanly and touches none of these 8 files, so I did not merge it in.
  • CI at b22b3b5: checks passes. Mintlify Deployment skipped because the base is not main, so no live preview was available.

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-doxie

stellar-doxie Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Automated message from the Stellar Triage Bot.

Back on this because @ElliotFriend rebased the stack after #3115 merged.

The rebase changed nothing on these 8 pages, and all checks pass. Ready to merge after #3123 and #3124. Your changes-requested review still needs clearing.

What I checked

@ElliotFriend ElliotFriend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Every point from my review is fixed: the Oxford commas, "Stellar network", and the root-relative increment link. The code changes are comment-only, so the earlier compile and testnet results still hold.

@ElliotFriend
ElliotFriend merged commit e4095c2 into main Nov 13, 2026
7 checks passed
@ElliotFriend
ElliotFriend deleted the docs-agent/1770-go-c branch November 13, 2026 16:16
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.

1 participant