Skip to content

[v2] docs(app-dev): add imports to app.go examples - #4731

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
agilgur5:fix-v2-app-dev-imports
Nov 30, 2025
Merged

leaanthony merged 3 commits into
wailsapp:masterfrom
agilgur5:fix-v2-app-dev-imports

Conversation

@agilgur5

@agilgur5 agilgur5 commented Nov 23, 2025 •

Copy link
Copy Markdown
Contributor

Description

  • add context and fmt imports to the app.go examples
  • link to the docs for context when it is referenced for explicitness/beginner-friendliness

Related to #4727; I also had to add these for a complete working example for the same SO answer

Future Work

  • imports could also be added the main.go examples on this page as well
    • that would be a bit more repetitive though (several similar code blocks) and would need to adjust various highlights, but let me know if desired. could also add it to the first main.go block only, but at least one more adds a new import

Fixes #N/A

Type of change

Docs bug fix

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Golang correctness was tested on the Go Playground (Linux): https://go.dev/play/p/tcWdPSMRCji
Visual spot check was done by running the local docs server with npm start (macOS)

  • Windows
  • macOS
  • Linux

Test Configuration

Go Playground. Docs-only change.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • [n/a] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • [n/a] I have added tests that prove my fix is effective or that my feature works
  • [n/a] New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Documentation
    • Updated the Application Development guide with an expanded code example demonstrating a simple greeting method and showing required imports.
  • Chore
    • Added a changelog entry noting the guide update and improved snippet clarity.

✏️ Tip: You can customize this high-level summary in your review settings.

- add `context` and `fmt` imports to the `app.go` examples
- link to the docs for `context` when it is referenced for explicitness/beginner-friendliness
@coderabbitai

coderabbitai Bot commented Nov 23, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Added a Greet(name string) string method to the App example in the Application Development guide and updated the example imports to include context and fmt. Also added a changelog entry noting the documentation update.

Changes

Cohort / File(s) Change Summary
Documentation: Application Development guide
website/docs/guides/application-development.mdx
Added Greet(name string) string method on App in the code example; added context and fmt imports; implemented Greet using fmt.Sprintf.
Changelog
website/src/pages/changelog.mdx
Added an Unreleased -> Fixed bullet noting the Application Development guide update and referencing PR #4731.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the code snippet compiles and the imports match the example.
  • Confirm changelog wording and PR reference are correct.

Suggested labels

Documentation, size:L, lgtm

Poem

I'm a rabbit in the docs, quick on my feet,
I added a greeting that's cheerful and neat,
With fmt I compose a friendly hello,
Greet gives warmth in a single go,
Hopping through guides — joy on repeat 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding imports to app.go examples in the application development guide documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description follows the template structure with complete Description, Type of change, How Has This Been Tested, and Checklist sections with most items appropriately marked.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3428ee2 and 5f2cbcc.

📒 Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
website/docs/guides/application-development.mdx (1)

35-35: Minor writing improvement: Consider rewording for clarity.

The phrase "This context is needed for calling the runtime" uses passive voice. Consider rephrasing to "You need this context to call the runtime" or replacing "needed" with "required" for a stronger tone.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c464b3 and 974f007.

📒 Files selected for processing (1)
  • website/docs/guides/application-development.mdx (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-04-18T05:57:34.711Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 4128
File: v3/examples/gin-service/services/gin_service.go:67-85
Timestamp: 2025-04-18T05:57:34.711Z
Learning: In Wails services (like GinService), initializing the app field in ServiceStartup rather than in the constructor is an acceptable pattern, as ServiceStartup is guaranteed to be called before any HTTP requests are handled.

Applied to files:

  • website/docs/guides/application-development.mdx
📚 Learning: 2025-11-21T07:21:52.552Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 4717
File: v3/pkg/application/application_darwin.go:349-349
Timestamp: 2025-11-21T07:21:52.552Z
Learning: In Go CGo code, the `//export FunctionName` directive must never be removed from functions that are called from C code. This directive is a compiler instruction that makes the Go function callable from C. Documentation comments should be placed before the `//export` line, not replace it.

Applied to files:

  • website/docs/guides/application-development.mdx
🪛 LanguageTool
website/docs/guides/application-development.mdx

[style] ~35-~35: To elevate your writing, try using a synonym like ‘required’ here. Or, to avoid using the passive voice, try replacing the past participle ‘needed’ with an adjective.
Context: ...aved in a struct field. This context is needed for calling the [runtime](../referenc...

(IS_NEEDED_NECESSARY)

🔇 Additional comments (2)
website/docs/guides/application-development.mdx (2)

13-15: Correct: import block completes the first code example.

Adding the context import is necessary, as context.Context is used throughout the example (lines 18, 25, 29). The code example is now complete and executable.


72-96: Correct: imports and new method complete the "Binding Methods" example.

The added context and fmt imports are both necessary:

  • context for the context.Context field on line 79
  • fmt for the fmt.Sprintf call in the new Greet method (line 94)

The Greet method is a clear, practical example of a public method that can be bound to the frontend. The code example is now complete and executable as demonstrated in the linked Go Playground example.

@leaanthony
leaanthony merged commit ef7d330 into wailsapp:master Nov 30, 2025
9 of 12 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@agilgur5
agilgur5 deleted the fix-v2-app-dev-imports branch November 30, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants