Visitar URL original
Add Go examples to the archival, conventions, rpc, conversions and events guides by stellar-triage-bot[bot] · Pull Request #3124 · stellar/stellar-docs · GitHub
Skip to content

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

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

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

Conversation

@stellar-triage-bot

@stellar-triage-bot stellar-triage-bot 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-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 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.

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.

1 participant