Skip to content

Add Go examples to the archival, conventions, rpc, conversions and events guides - #3124

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

ElliotFriend merged 3 commits into
docs-agent/1770-go-afrom
docs-agent/1770-go-b

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 B: Go tabs on the other 14 build/guides pages. Base: #3123 (docs-agent/1770-go-a). Go C, Go D and Java A to D follow.

What changed

  • A Go tab next to every Stellar SDK example on these 14 pages:
    • archival/: create-restoration-footprint, extend-persistent-entry, restore-contract, restore-data
    • conventions/: deploy-sac-with-code, extending-wasm-ttl
    • rpc/: generate-ledger-keys, retrieve-contract-code
    • conversions/: address-conversions, bytes-conversions, scval-conversions, string-conversions
    • events/: consume, ingest
  • Tab order is JavaScript, Python, Go. Three pages had another order, so I moved tabs:
    • bytes-conversions and string-conversions: Rust moved from first to last.
    • ingest: JavaScript moved before Python.
  • Every transaction bids the capped fee-stats p90, like the other tabs.
  • The Go SDK has no prepareTransaction. Where a page needs one, the Go tab defines a small helper and says so in one line. restore-data defines assembleTransaction for the same reason.
  • restore-contract and restore-data reuse the Go submitTx from submit-transaction-wait (Add Go examples to the transactions and basics guides #3123).
  • Prose changed only where it named JavaScript and Python alone.

A choice to confirm

  • The events pages need a database library. The Go tabs use GORM with gorm.io/driver/sqlite, the Go match for Prisma and SQLAlchemy. That driver needs cgo. Tell me if you prefer database/sql instead.
  • The Go storeEvents skips events already stored (OnConflict{DoNothing: true}). Each run starts again at the latest ingested ledger, so that ledger's events come back.

Skipped

Why this matters

Go readers had no example on these 14 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: clients/rpcclient/main.go, protocols/rpc/{get_events,get_ledger_entries,simulate_transaction,send_transaction,get_transaction,get_fee_stats,get_health}.go, txnbuild/{transaction,extend_footprint_ttl,restore_footprint,invoke_host_function,asset}.go, xdr/{xdr_generated,ledger_key,scval,account_id}.go, strkey/main.go. The pages pin no Go SDK version.
  • txnbuild.NewTransaction adds SorobanData.ResourceFee to the fee (transaction.go:902-926). So restore-data does not add minResourceFee by hand, unlike the JavaScript tab.
  • xdr.ScVal.String() prints a symbol as its text, an address as its strkey and an i32 as a number (scval.go:249-327). That gives the listener output on consume.
  • SegmentFilter.UnmarshalJSON takes * or a base64 ScVal (get_events.go:386-404), so ingest decodes the topic filter from the same JSON as the other tabs.
  • GORM v1.31.2: AfterCreate(*gorm.DB) error hook (callbacks/interfaces.go:9), clause.OnConflict.DoNothing, logger.LogMode. gorm.io/driver/sqlite v1.6.0 imports mattn/go-sqlite3 (cgo).
  • pnpm check passes: prettier, mint validate, no broken links.

Not verified

Overlaps

Found in passing, not fixed here

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

  1. conversions/bytes-conversions.mdx L23 and L26 (JavaScript): const addressFromBytes is declared twice in one block, a SyntaxError.
  2. events/ingest.mdx (JavaScript):
    • L210: latestEventIngested is null on an empty database, so .ledger throws.
    • L342: forEach(async ...) does not wait for the writes.
    • L348: event.contractId! is TypeScript syntax in a javascript block.
  3. events/ingest.mdx L238 (Python): uses contract_id before L251 defines it.

@stellar-doxie
stellar-doxie Bot added this pull request to stack #3118 November 13, 2026 05:12
@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 my own PR, which the issue lane opened for #1770.

Verified: every Go symbol matches go-stellar-sdk v0.9.0 (newest) and GORM v1.31.2. Not run: the Go blocks on all 14 pages, which a maintainer runs before merge. Merge #3115, then #3123, then this PR. Ready to merge.

What I checked
  • Pushed a82cdc0: the Go streaming tab in events/consume.mdx said "no database event listeners either". "Either" pointed at the JavaScript tab, which a Go reader does not see. I removed it.
  • Checked against go-stellar-sdk v0.9.0 (newest, go 1.25.0 in go.mod). The pages pin no Go SDK version.
  • Confirmed every "Verified" line in the PR body against the source. The body did not list these extra checks:
    • Transaction.Timebounds() keeps the built flag, so assembleTransaction passes Preconditions.Validate (txnbuild/timebounds.go:24-33).
    • submitTx from Add Go examples to the transactions and basics guides #3123 imports context, errors, fmt, time, txnbuild, rpcclient and protocol, so the extra-import notes on restore-contract and restore-data are complete.
    • Every package main block has no unused or missing import.
    • The XDR literals decode by hand to the values in the comments (transfer, i32 10000/5000/1000, the contract code key on retrieve-contract-code).
  • Tab order is JavaScript, Python, Go in every group. The ingest Setup group has no JavaScript tab on main either.
  • New links (gorm.io, the GORM hooks page, go.dev/doc/install, the go-stellar-sdk repo) all return 200.
  • Checks at a82cdc0: checks, CodeQL and Socket pass. Mintlify Deployment skips on a stacked base, so no live preview was available.
  • "Found in passing" defects: confirmed at the cited lines. Fix defects in existing code examples found while adding Python (#3115) #3119 still has bot:hands-off, so they stay in the PR body.
  • Open choice in the body (non-blocking): GORM with the cgo SQLite driver, like Prisma and SQLAlchemy on the other tabs. Say if you prefer database/sql.

@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. Conversion outputs match the JavaScript tab exactly. A few fixes before merge:

Code

  • events/consume.mdx:322: var events []StellarEvent redeclares events from :203 when the blocks share one main (events redeclared in this block). Rename it (for example allEvents). The JavaScript tab has the same clash with const events, so fix it there too.
  • conventions/deploy-sac-with-code.mdx:148: following the comment doesn't compile either way. In a separate file the rpcclient import is unused; pasted into this file, it needs errors and time. Say which imports to adjust.
  • conversions/string-conversions.mdx:75: the fragment calls log.Fatal but doesn't import log.
  • Each page's prepareTransaction asserts one operation type and panics on any other. Add a one-line comment saying so.

Prose and comments

  • Oxford comma: extend-persistent-entry.mdx:36, :203; deploy-sac-with-code.mdx:513; extending-wasm-ttl.mdx:354, :436; address-conversions.mdx:12; events/ingest.mdx:10; and the prepareTransaction doc comment on every 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 requested changes.

Pushed 64bf325, which fixes every point in the review. checks, CodeQL and Socket pass. Not run: the changed Go blocks, so please re-run them. Merge #3115, then #3123, then this PR. Ready to merge.

What I checked
  • events/consume.mdx: renamed the Go slice and the JavaScript const events to allEvents. The JavaScript name clashed with let { events } in the ingest guide (ingest.mdx:209).
  • conventions/deploy-sac-with-code.mdx:148: the comment now names the imports. In this file, add errors and time and leave out rpcServer and server. In a separate file, copy the imports of submitTx but drop rpcclient. I checked this against the submitTx imports on submit-transaction-wait.mdx.
  • conversions/string-conversions.mdx: the fragment now imports log. The scval-conversions fragments show no import block, like their JavaScript and Python tabs, so I left them as they are.
  • prepareTransaction on extend-persistent-entry, extending-wasm-ttl, restore-contract and deploy-sac-with-code: added a one-line comment that it takes one operation type and panics on any other. assembleTransaction on restore-data already returns an error, not a panic.
  • Oxford commas: fixed every spot you listed and every helper doc comment. I also fixed one more at extend-persistent-entry.mdx:841 (getWasmHash(), and).
  • The branch still merges cleanly onto Add Go examples to the transactions and basics guides #3123's new head 9b1d03d. Mintlify Deployment skips on a stacked base, so no live preview was available.

@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 GitHub rebased the stack after #3115 merged.

The rebase changed no content: all three commits match 64bf325 and the fixes for @ElliotFriend's review. Checks pass. Not run: the Go blocks changed in 64bf325. Merge #3123, then this PR. Ready to merge.

What I checked
  • git range-diff 9084e7cc..64bf325c 9918ea48..6a6c0925: all three commits are identical patches.
  • The new base commits touch none of this PR's files. submitTx on submit-transaction-wait.mdx did not change, so the import notes still hold.
  • The Go fee bids use the capped SorobanInclusionFee.P90. This PR adds no poll loops. It calls submitTx from Add Go examples to the transactions and basics guides #3123.
  • Checks at 6a6c092: checks, CodeQL and Socket pass. mint broken-links found no broken links.
  • Mintlify Deployment does not run while the base is Add Go examples to the transactions and basics guides #3123's branch, so no live preview was available.

@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.

  • events/consume.mdx: with allEvents, the Go blocks now build and pass go vet in one main, with nothing extra added.
  • deploy-sac-with-code.mdx:148: the comment now names the right lines (rpcServer and server) and the imports to adjust.
  • string-conversions.mdx: the fragment imports log.
  • The single-operation notes and the Oxford commas look good.

@ElliotFriend
ElliotFriend merged commit 8062b72 into main Nov 13, 2026
7 checks passed
@ElliotFriend
ElliotFriend deleted the docs-agent/1770-go-b 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