[v2] docs(app-dev): add imports to app.go examples - #4731
Conversation
- add `context` and `fmt` imports to the `app.go` examples - link to the docs for `context` when it is referenced for explicitness/beginner-friendliness
|
Caution Review failedThe pull request is closed. WalkthroughAdded a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
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. Comment |
There was a problem hiding this comment.
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
📒 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
contextimport is necessary, ascontext.Contextis 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
contextandfmtimports are both necessary:
contextfor thecontext.Contextfield on line 79fmtfor thefmt.Sprintfcall in the newGreetmethod (line 94)The
Greetmethod 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.
|



Description
contextandfmtimports to theapp.goexamplescontextwhen it is referenced for explicitness/beginner-friendlinessRelated to #4727; I also had to add these for a complete working example for the same SO answer
Future Work
main.goexamples on this page as wellmain.goblock only, but at least one more adds a new importFixes #N/A
Type of change
Docs bug fix
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)Test Configuration
Go Playground. Docs-only change.
Checklist:
website/src/pages/changelog.mdxwith details of this PRSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.