docs: replace raw AST dumps with descriptive markdown (#34)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
parent
f0f6dafc1d
commit
456a5d6864
9 changed files with 298 additions and 5827 deletions
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"embed"
|
"embed"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/Snider/Core/runtime"
|
"github.com/Snider/Core"
|
||||||
"github.com/wailsapp/wails/v3/pkg/application"
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,12 +35,12 @@ func main() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
rt, err := runtime.New(app)
|
rt, err := core.NewRuntime(app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Services.Add(application.NewService(rt))
|
app.RegisterService(application.NewService(rt))
|
||||||
|
|
||||||
err = app.Run()
|
err = app.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,604 +1,37 @@
|
||||||
---
|
---
|
||||||
title: internal
|
title: config
|
||||||
---
|
---
|
||||||
# Service: `internal`
|
# Service: `config`
|
||||||
|
|
||||||
|
The `config` service provides a unified interface for managing application configuration. It handles retrieving and setting configuration values, persistent storage, and feature flags.
|
||||||
|
|
||||||
|
## Interfaces
|
||||||
|
|
||||||
|
### `type Config`
|
||||||
|
|
||||||
## Constants
|
`Config` defines the contract for the configuration service.
|
||||||
|
|
||||||
```goappName
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
```goconfigFileName
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Types
|
|
||||||
|
|
||||||
### `type Options`
|
|
||||||
```go
|
```go
|
||||||
type Options 0 *ast.StructType {
|
type Config interface {
|
||||||
1 . Struct: -
|
// Get retrieves a configuration value by key and stores it in the 'out' variable.
|
||||||
2 . Fields: *ast.FieldList {
|
Get(key string, out any) error
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: nil
|
|
||||||
5 . . Closing: -
|
|
||||||
6 . }
|
|
||||||
7 . Incomplete: false
|
|
||||||
8 }
|
|
||||||
|
|
||||||
|
// Set stores a configuration value by key.
|
||||||
|
Set(key string, v any) error
|
||||||
|
}
|
||||||
```
|
```
|
||||||
Options holds configuration for the config service.
|
|
||||||
|
|
||||||
|
## Standard Implementation
|
||||||
|
|
||||||
|
While `Config` is an interface, the standard implementation typically provides the following functionality:
|
||||||
|
|
||||||
|
- **Persistent Storage**: Saves configuration to disk (e.g., `config.json`).
|
||||||
|
- **Feature Flags**: Checking if specific application features are enabled.
|
||||||
|
- **Defaults**: Providing default values for configuration settings.
|
||||||
|
|
||||||
|
### Common Methods
|
||||||
|
|
||||||
### `type Service`
|
Although not part of the minimal `Config` interface, implementations often provide:
|
||||||
```go
|
|
||||||
type Service 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 11) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.StarExpr {
|
|
||||||
9 . . . . . Star: -
|
|
||||||
10 . . . . . X: *ast.IndexExpr {
|
|
||||||
11 . . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . . Name: "core"
|
|
||||||
15 . . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . . }
|
|
||||||
17 . . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . . Name: "Runtime"
|
|
||||||
20 . . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . . }
|
|
||||||
22 . . . . . . }
|
|
||||||
23 . . . . . . Lbrack: -
|
|
||||||
24 . . . . . . Index: *ast.Ident {
|
|
||||||
25 . . . . . . . NamePos: -
|
|
||||||
26 . . . . . . . Name: "Options"
|
|
||||||
27 . . . . . . . Obj: *ast.Object {
|
|
||||||
28 . . . . . . . . Kind: type
|
|
||||||
29 . . . . . . . . Name: "Options"
|
|
||||||
30 . . . . . . . . Decl: *ast.TypeSpec {
|
|
||||||
31 . . . . . . . . . Doc: nil
|
|
||||||
32 . . . . . . . . . Name: *ast.Ident {
|
|
||||||
33 . . . . . . . . . . NamePos: -
|
|
||||||
34 . . . . . . . . . . Name: "Options"
|
|
||||||
35 . . . . . . . . . . Obj: *(obj @ 27)
|
|
||||||
36 . . . . . . . . . }
|
|
||||||
37 . . . . . . . . . TypeParams: nil
|
|
||||||
38 . . . . . . . . . Assign: -
|
|
||||||
39 . . . . . . . . . Type: *ast.StructType {
|
|
||||||
40 . . . . . . . . . . Struct: -
|
|
||||||
41 . . . . . . . . . . Fields: *ast.FieldList {
|
|
||||||
42 . . . . . . . . . . . Opening: -
|
|
||||||
43 . . . . . . . . . . . List: nil
|
|
||||||
44 . . . . . . . . . . . Closing: -
|
|
||||||
45 . . . . . . . . . . }
|
|
||||||
46 . . . . . . . . . . Incomplete: false
|
|
||||||
47 . . . . . . . . . }
|
|
||||||
48 . . . . . . . . . Comment: nil
|
|
||||||
49 . . . . . . . . }
|
|
||||||
50 . . . . . . . . Data: nil
|
|
||||||
51 . . . . . . . . Type: nil
|
|
||||||
52 . . . . . . . }
|
|
||||||
53 . . . . . . }
|
|
||||||
54 . . . . . . Rbrack: -
|
|
||||||
55 . . . . . }
|
|
||||||
56 . . . . }
|
|
||||||
57 . . . . Tag: *ast.BasicLit {
|
|
||||||
58 . . . . . ValuePos: -
|
|
||||||
59 . . . . . Kind: STRING
|
|
||||||
60 . . . . . Value: "`json:\"-\"`"
|
|
||||||
61 . . . . }
|
|
||||||
62 . . . . Comment: nil
|
|
||||||
63 . . . }
|
|
||||||
64 . . . 1: *ast.Field {
|
|
||||||
65 . . . . Doc: *ast.CommentGroup {
|
|
||||||
66 . . . . . List: []*ast.Comment (len = 1) {
|
|
||||||
67 . . . . . . 0: *ast.Comment {
|
|
||||||
68 . . . . . . . Slash: -
|
|
||||||
69 . . . . . . . Text: "// Persistent fields, saved to config.json."
|
|
||||||
70 . . . . . . }
|
|
||||||
71 . . . . . }
|
|
||||||
72 . . . . }
|
|
||||||
73 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
74 . . . . . 0: *ast.Ident {
|
|
||||||
75 . . . . . . NamePos: -
|
|
||||||
76 . . . . . . Name: "ConfigPath"
|
|
||||||
77 . . . . . . Obj: *ast.Object {
|
|
||||||
78 . . . . . . . Kind: var
|
|
||||||
79 . . . . . . . Name: "ConfigPath"
|
|
||||||
80 . . . . . . . Decl: *(obj @ 64)
|
|
||||||
81 . . . . . . . Data: nil
|
|
||||||
82 . . . . . . . Type: nil
|
|
||||||
83 . . . . . . }
|
|
||||||
84 . . . . . }
|
|
||||||
85 . . . . }
|
|
||||||
86 . . . . Type: *ast.Ident {
|
|
||||||
87 . . . . . NamePos: -
|
|
||||||
88 . . . . . Name: "string"
|
|
||||||
89 . . . . . Obj: nil
|
|
||||||
90 . . . . }
|
|
||||||
91 . . . . Tag: *ast.BasicLit {
|
|
||||||
92 . . . . . ValuePos: -
|
|
||||||
93 . . . . . Kind: STRING
|
|
||||||
94 . . . . . Value: "`json:\"configPath,omitempty\"`"
|
|
||||||
95 . . . . }
|
|
||||||
96 . . . . Comment: nil
|
|
||||||
97 . . . }
|
|
||||||
98 . . . 2: *ast.Field {
|
|
||||||
99 . . . . Doc: nil
|
|
||||||
100 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
101 . . . . . 0: *ast.Ident {
|
|
||||||
102 . . . . . . NamePos: -
|
|
||||||
103 . . . . . . Name: "UserHomeDir"
|
|
||||||
104 . . . . . . Obj: *ast.Object {
|
|
||||||
105 . . . . . . . Kind: var
|
|
||||||
106 . . . . . . . Name: "UserHomeDir"
|
|
||||||
107 . . . . . . . Decl: *(obj @ 98)
|
|
||||||
108 . . . . . . . Data: nil
|
|
||||||
109 . . . . . . . Type: nil
|
|
||||||
110 . . . . . . }
|
|
||||||
111 . . . . . }
|
|
||||||
112 . . . . }
|
|
||||||
113 . . . . Type: *ast.Ident {
|
|
||||||
114 . . . . . NamePos: -
|
|
||||||
115 . . . . . Name: "string"
|
|
||||||
116 . . . . . Obj: nil
|
|
||||||
117 . . . . }
|
|
||||||
118 . . . . Tag: *ast.BasicLit {
|
|
||||||
119 . . . . . ValuePos: -
|
|
||||||
120 . . . . . Kind: STRING
|
|
||||||
121 . . . . . Value: "`json:\"userHomeDir,omitempty\"`"
|
|
||||||
122 . . . . }
|
|
||||||
123 . . . . Comment: nil
|
|
||||||
124 . . . }
|
|
||||||
125 . . . 3: *ast.Field {
|
|
||||||
126 . . . . Doc: nil
|
|
||||||
127 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
128 . . . . . 0: *ast.Ident {
|
|
||||||
129 . . . . . . NamePos: -
|
|
||||||
130 . . . . . . Name: "RootDir"
|
|
||||||
131 . . . . . . Obj: *ast.Object {
|
|
||||||
132 . . . . . . . Kind: var
|
|
||||||
133 . . . . . . . Name: "RootDir"
|
|
||||||
134 . . . . . . . Decl: *(obj @ 125)
|
|
||||||
135 . . . . . . . Data: nil
|
|
||||||
136 . . . . . . . Type: nil
|
|
||||||
137 . . . . . . }
|
|
||||||
138 . . . . . }
|
|
||||||
139 . . . . }
|
|
||||||
140 . . . . Type: *ast.Ident {
|
|
||||||
141 . . . . . NamePos: -
|
|
||||||
142 . . . . . Name: "string"
|
|
||||||
143 . . . . . Obj: nil
|
|
||||||
144 . . . . }
|
|
||||||
145 . . . . Tag: *ast.BasicLit {
|
|
||||||
146 . . . . . ValuePos: -
|
|
||||||
147 . . . . . Kind: STRING
|
|
||||||
148 . . . . . Value: "`json:\"rootDir,omitempty\"`"
|
|
||||||
149 . . . . }
|
|
||||||
150 . . . . Comment: nil
|
|
||||||
151 . . . }
|
|
||||||
152 . . . 4: *ast.Field {
|
|
||||||
153 . . . . Doc: nil
|
|
||||||
154 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
155 . . . . . 0: *ast.Ident {
|
|
||||||
156 . . . . . . NamePos: -
|
|
||||||
157 . . . . . . Name: "CacheDir"
|
|
||||||
158 . . . . . . Obj: *ast.Object {
|
|
||||||
159 . . . . . . . Kind: var
|
|
||||||
160 . . . . . . . Name: "CacheDir"
|
|
||||||
161 . . . . . . . Decl: *(obj @ 152)
|
|
||||||
162 . . . . . . . Data: nil
|
|
||||||
163 . . . . . . . Type: nil
|
|
||||||
164 . . . . . . }
|
|
||||||
165 . . . . . }
|
|
||||||
166 . . . . }
|
|
||||||
167 . . . . Type: *ast.Ident {
|
|
||||||
168 . . . . . NamePos: -
|
|
||||||
169 . . . . . Name: "string"
|
|
||||||
170 . . . . . Obj: nil
|
|
||||||
171 . . . . }
|
|
||||||
172 . . . . Tag: *ast.BasicLit {
|
|
||||||
173 . . . . . ValuePos: -
|
|
||||||
174 . . . . . Kind: STRING
|
|
||||||
175 . . . . . Value: "`json:\"cacheDir,omitempty\"`"
|
|
||||||
176 . . . . }
|
|
||||||
177 . . . . Comment: nil
|
|
||||||
178 . . . }
|
|
||||||
179 . . . 5: *ast.Field {
|
|
||||||
180 . . . . Doc: nil
|
|
||||||
181 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
182 . . . . . 0: *ast.Ident {
|
|
||||||
183 . . . . . . NamePos: -
|
|
||||||
184 . . . . . . Name: "ConfigDir"
|
|
||||||
185 . . . . . . Obj: *ast.Object {
|
|
||||||
186 . . . . . . . Kind: var
|
|
||||||
187 . . . . . . . Name: "ConfigDir"
|
|
||||||
188 . . . . . . . Decl: *(obj @ 179)
|
|
||||||
189 . . . . . . . Data: nil
|
|
||||||
190 . . . . . . . Type: nil
|
|
||||||
191 . . . . . . }
|
|
||||||
192 . . . . . }
|
|
||||||
193 . . . . }
|
|
||||||
194 . . . . Type: *ast.Ident {
|
|
||||||
195 . . . . . NamePos: -
|
|
||||||
196 . . . . . Name: "string"
|
|
||||||
197 . . . . . Obj: nil
|
|
||||||
198 . . . . }
|
|
||||||
199 . . . . Tag: *ast.BasicLit {
|
|
||||||
200 . . . . . ValuePos: -
|
|
||||||
201 . . . . . Kind: STRING
|
|
||||||
202 . . . . . Value: "`json:\"configDir,omitempty\"`"
|
|
||||||
203 . . . . }
|
|
||||||
204 . . . . Comment: nil
|
|
||||||
205 . . . }
|
|
||||||
206 . . . 6: *ast.Field {
|
|
||||||
207 . . . . Doc: nil
|
|
||||||
208 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
209 . . . . . 0: *ast.Ident {
|
|
||||||
210 . . . . . . NamePos: -
|
|
||||||
211 . . . . . . Name: "DataDir"
|
|
||||||
212 . . . . . . Obj: *ast.Object {
|
|
||||||
213 . . . . . . . Kind: var
|
|
||||||
214 . . . . . . . Name: "DataDir"
|
|
||||||
215 . . . . . . . Decl: *(obj @ 206)
|
|
||||||
216 . . . . . . . Data: nil
|
|
||||||
217 . . . . . . . Type: nil
|
|
||||||
218 . . . . . . }
|
|
||||||
219 . . . . . }
|
|
||||||
220 . . . . }
|
|
||||||
221 . . . . Type: *ast.Ident {
|
|
||||||
222 . . . . . NamePos: -
|
|
||||||
223 . . . . . Name: "string"
|
|
||||||
224 . . . . . Obj: nil
|
|
||||||
225 . . . . }
|
|
||||||
226 . . . . Tag: *ast.BasicLit {
|
|
||||||
227 . . . . . ValuePos: -
|
|
||||||
228 . . . . . Kind: STRING
|
|
||||||
229 . . . . . Value: "`json:\"dataDir,omitempty\"`"
|
|
||||||
230 . . . . }
|
|
||||||
231 . . . . Comment: nil
|
|
||||||
232 . . . }
|
|
||||||
233 . . . 7: *ast.Field {
|
|
||||||
234 . . . . Doc: nil
|
|
||||||
235 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
236 . . . . . 0: *ast.Ident {
|
|
||||||
237 . . . . . . NamePos: -
|
|
||||||
238 . . . . . . Name: "WorkspaceDir"
|
|
||||||
239 . . . . . . Obj: *ast.Object {
|
|
||||||
240 . . . . . . . Kind: var
|
|
||||||
241 . . . . . . . Name: "WorkspaceDir"
|
|
||||||
242 . . . . . . . Decl: *(obj @ 233)
|
|
||||||
243 . . . . . . . Data: nil
|
|
||||||
244 . . . . . . . Type: nil
|
|
||||||
245 . . . . . . }
|
|
||||||
246 . . . . . }
|
|
||||||
247 . . . . }
|
|
||||||
248 . . . . Type: *ast.Ident {
|
|
||||||
249 . . . . . NamePos: -
|
|
||||||
250 . . . . . Name: "string"
|
|
||||||
251 . . . . . Obj: nil
|
|
||||||
252 . . . . }
|
|
||||||
253 . . . . Tag: *ast.BasicLit {
|
|
||||||
254 . . . . . ValuePos: -
|
|
||||||
255 . . . . . Kind: STRING
|
|
||||||
256 . . . . . Value: "`json:\"workspaceDir,omitempty\"`"
|
|
||||||
257 . . . . }
|
|
||||||
258 . . . . Comment: nil
|
|
||||||
259 . . . }
|
|
||||||
260 . . . 8: *ast.Field {
|
|
||||||
261 . . . . Doc: nil
|
|
||||||
262 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
263 . . . . . 0: *ast.Ident {
|
|
||||||
264 . . . . . . NamePos: -
|
|
||||||
265 . . . . . . Name: "DefaultRoute"
|
|
||||||
266 . . . . . . Obj: *ast.Object {
|
|
||||||
267 . . . . . . . Kind: var
|
|
||||||
268 . . . . . . . Name: "DefaultRoute"
|
|
||||||
269 . . . . . . . Decl: *(obj @ 260)
|
|
||||||
270 . . . . . . . Data: nil
|
|
||||||
271 . . . . . . . Type: nil
|
|
||||||
272 . . . . . . }
|
|
||||||
273 . . . . . }
|
|
||||||
274 . . . . }
|
|
||||||
275 . . . . Type: *ast.Ident {
|
|
||||||
276 . . . . . NamePos: -
|
|
||||||
277 . . . . . Name: "string"
|
|
||||||
278 . . . . . Obj: nil
|
|
||||||
279 . . . . }
|
|
||||||
280 . . . . Tag: *ast.BasicLit {
|
|
||||||
281 . . . . . ValuePos: -
|
|
||||||
282 . . . . . Kind: STRING
|
|
||||||
283 . . . . . Value: "`json:\"default_route\"`"
|
|
||||||
284 . . . . }
|
|
||||||
285 . . . . Comment: nil
|
|
||||||
286 . . . }
|
|
||||||
287 . . . 9: *ast.Field {
|
|
||||||
288 . . . . Doc: nil
|
|
||||||
289 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
290 . . . . . 0: *ast.Ident {
|
|
||||||
291 . . . . . . NamePos: -
|
|
||||||
292 . . . . . . Name: "Features"
|
|
||||||
293 . . . . . . Obj: *ast.Object {
|
|
||||||
294 . . . . . . . Kind: var
|
|
||||||
295 . . . . . . . Name: "Features"
|
|
||||||
296 . . . . . . . Decl: *(obj @ 287)
|
|
||||||
297 . . . . . . . Data: nil
|
|
||||||
298 . . . . . . . Type: nil
|
|
||||||
299 . . . . . . }
|
|
||||||
300 . . . . . }
|
|
||||||
301 . . . . }
|
|
||||||
302 . . . . Type: *ast.ArrayType {
|
|
||||||
303 . . . . . Lbrack: -
|
|
||||||
304 . . . . . Len: nil
|
|
||||||
305 . . . . . Elt: *ast.Ident {
|
|
||||||
306 . . . . . . NamePos: -
|
|
||||||
307 . . . . . . Name: "string"
|
|
||||||
308 . . . . . . Obj: nil
|
|
||||||
309 . . . . . }
|
|
||||||
310 . . . . }
|
|
||||||
311 . . . . Tag: *ast.BasicLit {
|
|
||||||
312 . . . . . ValuePos: -
|
|
||||||
313 . . . . . Kind: STRING
|
|
||||||
314 . . . . . Value: "`json:\"features\"`"
|
|
||||||
315 . . . . }
|
|
||||||
316 . . . . Comment: nil
|
|
||||||
317 . . . }
|
|
||||||
318 . . . 10: *ast.Field {
|
|
||||||
319 . . . . Doc: nil
|
|
||||||
320 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
321 . . . . . 0: *ast.Ident {
|
|
||||||
322 . . . . . . NamePos: -
|
|
||||||
323 . . . . . . Name: "Language"
|
|
||||||
324 . . . . . . Obj: *ast.Object {
|
|
||||||
325 . . . . . . . Kind: var
|
|
||||||
326 . . . . . . . Name: "Language"
|
|
||||||
327 . . . . . . . Decl: *(obj @ 318)
|
|
||||||
328 . . . . . . . Data: nil
|
|
||||||
329 . . . . . . . Type: nil
|
|
||||||
330 . . . . . . }
|
|
||||||
331 . . . . . }
|
|
||||||
332 . . . . }
|
|
||||||
333 . . . . Type: *ast.Ident {
|
|
||||||
334 . . . . . NamePos: -
|
|
||||||
335 . . . . . Name: "string"
|
|
||||||
336 . . . . . Obj: nil
|
|
||||||
337 . . . . }
|
|
||||||
338 . . . . Tag: *ast.BasicLit {
|
|
||||||
339 . . . . . ValuePos: -
|
|
||||||
340 . . . . . Kind: STRING
|
|
||||||
341 . . . . . Value: "`json:\"language\"`"
|
|
||||||
342 . . . . }
|
|
||||||
343 . . . . Comment: nil
|
|
||||||
344 . . . }
|
|
||||||
345 . . }
|
|
||||||
346 . . Closing: -
|
|
||||||
347 . }
|
|
||||||
348 . Incomplete: false
|
|
||||||
349 }
|
|
||||||
|
|
||||||
```
|
- `Save() error`: Explicitly saves the current configuration to disk.
|
||||||
Service provides access to the application's configuration.
|
- `IsFeatureEnabled(feature string) bool`: Checks if a feature flag is active.
|
||||||
It handles loading, saving, and providing access to configuration values.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Methods
|
|
||||||
|
|
||||||
- `Get(key 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, out 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Get retrieves a configuration value by its key.
|
|
||||||
|
|
||||||
- `IsFeatureEnabled(feature 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "bool"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: IsFeatureEnabled checks if a specific feature is enabled in the config.
|
|
||||||
|
|
||||||
- `Save() 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Save writes the current configuration to config.json.
|
|
||||||
|
|
||||||
- `Set(key 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, v 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Set updates a configuration value and saves the config.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `Register(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initializes its core.Runtime field.
|
|
||||||
|
|
||||||
- `TestConfigService(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `TestIsFeatureEnabled(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `TestSet_Bad(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `TestSet_Good(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `TestSet_Ugly(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `setupTestEnv(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.FuncType {
|
|
||||||
1 . Func: -
|
|
||||||
2 . TypeParams: nil
|
|
||||||
3 . Params: *ast.FieldList {
|
|
||||||
4 . . Opening: -
|
|
||||||
5 . . List: nil
|
|
||||||
6 . . Closing: -
|
|
||||||
7 . }
|
|
||||||
8 . Results: nil
|
|
||||||
9 }
|
|
||||||
`: setupTestEnv creates a temporary home directory for testing and ensures a clean environment.
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,335 +1,59 @@
|
||||||
---
|
---
|
||||||
title: internal
|
title: crypt
|
||||||
---
|
---
|
||||||
# Service: `internal`
|
# Service: `crypt`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The `crypt` service provides cryptographic utilities for the application, including hashing, checksums, and PGP encryption/decryption.
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
### `type HashType`
|
### `type HashType`
|
||||||
|
|
||||||
|
`HashType` defines the supported hashing algorithms.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type HashType 0 *ast.Ident {
|
type HashType string
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
|
|
||||||
```
|
```
|
||||||
HashType defines the supported hashing algorithms.
|
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### `func EncryptPGP(writer io.Writer, recipientPath, data string, signerPath, signerPassphrase *string) (string, error)`
|
||||||
|
|
||||||
|
`EncryptPGP` encrypts data for a specific recipient.
|
||||||
|
- **writer**: Optional output writer.
|
||||||
|
- **recipientPath**: Path to the recipient's public key.
|
||||||
|
- **data**: The data to encrypt.
|
||||||
|
- **signerPath**: Optional path to a private key to sign the message.
|
||||||
|
- **signerPassphrase**: Optional passphrase for the signing key.
|
||||||
|
|
||||||
|
Returns the encrypted data as a string.
|
||||||
|
|
||||||
### `type Options`
|
### `func DecryptPGP(recipientPath, message, passphrase string, signerPath *string) (string, error)`
|
||||||
```go
|
|
||||||
type Options 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: nil
|
|
||||||
5 . . Closing: -
|
|
||||||
6 . }
|
|
||||||
7 . Incomplete: false
|
|
||||||
8 }
|
|
||||||
|
|
||||||
```
|
`DecryptPGP` decrypts a PGP message.
|
||||||
Options holds configuration for the crypt service.
|
- **recipientPath**: Path to the private key for decryption.
|
||||||
|
- **message**: The encrypted message (armor encoded).
|
||||||
|
- **passphrase**: Passphrase for the private key.
|
||||||
|
- **signerPath**: Optional path to the sender's public key to verify the signature.
|
||||||
|
|
||||||
|
Returns the decrypted string.
|
||||||
|
|
||||||
|
### `func Hash(lib HashType, payload string) string`
|
||||||
|
|
||||||
|
`Hash` computes a hash of the payload using the specified algorithm (e.g., MD5, SHA256).
|
||||||
|
|
||||||
|
### `func Fletcher16(payload string) uint16`
|
||||||
|
|
||||||
### `type Service`
|
`Fletcher16` computes the Fletcher-16 checksum of the payload.
|
||||||
```go
|
|
||||||
type Service 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 1) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.StarExpr {
|
|
||||||
9 . . . . . Star: -
|
|
||||||
10 . . . . . X: *ast.IndexExpr {
|
|
||||||
11 . . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . . Name: "core"
|
|
||||||
15 . . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . . }
|
|
||||||
17 . . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . . Name: "Runtime"
|
|
||||||
20 . . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . . }
|
|
||||||
22 . . . . . . }
|
|
||||||
23 . . . . . . Lbrack: -
|
|
||||||
24 . . . . . . Index: *ast.Ident {
|
|
||||||
25 . . . . . . . NamePos: -
|
|
||||||
26 . . . . . . . Name: "Options"
|
|
||||||
27 . . . . . . . Obj: *ast.Object {
|
|
||||||
28 . . . . . . . . Kind: type
|
|
||||||
29 . . . . . . . . Name: "Options"
|
|
||||||
30 . . . . . . . . Decl: *ast.TypeSpec {
|
|
||||||
31 . . . . . . . . . Doc: nil
|
|
||||||
32 . . . . . . . . . Name: *ast.Ident {
|
|
||||||
33 . . . . . . . . . . NamePos: -
|
|
||||||
34 . . . . . . . . . . Name: "Options"
|
|
||||||
35 . . . . . . . . . . Obj: *(obj @ 27)
|
|
||||||
36 . . . . . . . . . }
|
|
||||||
37 . . . . . . . . . TypeParams: nil
|
|
||||||
38 . . . . . . . . . Assign: -
|
|
||||||
39 . . . . . . . . . Type: *ast.StructType {
|
|
||||||
40 . . . . . . . . . . Struct: -
|
|
||||||
41 . . . . . . . . . . Fields: *ast.FieldList {
|
|
||||||
42 . . . . . . . . . . . Opening: -
|
|
||||||
43 . . . . . . . . . . . List: nil
|
|
||||||
44 . . . . . . . . . . . Closing: -
|
|
||||||
45 . . . . . . . . . . }
|
|
||||||
46 . . . . . . . . . . Incomplete: false
|
|
||||||
47 . . . . . . . . . }
|
|
||||||
48 . . . . . . . . . Comment: nil
|
|
||||||
49 . . . . . . . . }
|
|
||||||
50 . . . . . . . . Data: nil
|
|
||||||
51 . . . . . . . . Type: nil
|
|
||||||
52 . . . . . . . }
|
|
||||||
53 . . . . . . }
|
|
||||||
54 . . . . . . Rbrack: -
|
|
||||||
55 . . . . . }
|
|
||||||
56 . . . . }
|
|
||||||
57 . . . . Tag: nil
|
|
||||||
58 . . . . Comment: nil
|
|
||||||
59 . . . }
|
|
||||||
60 . . }
|
|
||||||
61 . . Closing: -
|
|
||||||
62 . }
|
|
||||||
63 . Incomplete: false
|
|
||||||
64 }
|
|
||||||
|
|
||||||
```
|
### `func Fletcher32(payload string) uint32`
|
||||||
Service provides cryptographic functions to the application.
|
|
||||||
|
|
||||||
|
`Fletcher32` computes the Fletcher-32 checksum of the payload.
|
||||||
|
|
||||||
|
### `func Fletcher64(payload string) uint64`
|
||||||
|
|
||||||
#### Methods
|
`Fletcher64` computes the Fletcher-64 checksum of the payload.
|
||||||
|
|
||||||
- `DecryptPGP(recipientPath, message, passphrase 0 *ast.Ident {
|
### `func Luhn(payload string) bool`
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, signerPath 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "string"
|
|
||||||
5 . . Obj: nil
|
|
||||||
6 . }
|
|
||||||
7 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: DecryptPGP decrypts a PGP message, optionally verifying the signature.
|
|
||||||
|
|
||||||
- `EncryptPGP(writer 0 *ast.SelectorExpr {
|
`Luhn` validates a number string using the Luhn algorithm (commonly used for credit card numbers).
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "io"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Writer"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
, recipientPath, data 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, signerPath, signerPassphrase 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "string"
|
|
||||||
5 . . Obj: nil
|
|
||||||
6 . }
|
|
||||||
7 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: EncryptPGP encrypts data for a recipient, optionally signing it.
|
|
||||||
|
|
||||||
- `Fletcher16(payload 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "uint16"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Fletcher16 computes the Fletcher-16 checksum.
|
|
||||||
|
|
||||||
- `Fletcher32(payload 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "uint32"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Fletcher32 computes the Fletcher-32 checksum.
|
|
||||||
|
|
||||||
- `Fletcher64(payload 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "uint64"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Fletcher64 computes the Fletcher-64 checksum.
|
|
||||||
|
|
||||||
- `Hash(lib 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "HashType"
|
|
||||||
3 . Obj: *ast.Object {
|
|
||||||
4 . . Kind: type
|
|
||||||
5 . . Name: "HashType"
|
|
||||||
6 . . Decl: *ast.TypeSpec {
|
|
||||||
7 . . . Doc: nil
|
|
||||||
8 . . . Name: *ast.Ident {
|
|
||||||
9 . . . . NamePos: -
|
|
||||||
10 . . . . Name: "HashType"
|
|
||||||
11 . . . . Obj: *(obj @ 3)
|
|
||||||
12 . . . }
|
|
||||||
13 . . . TypeParams: nil
|
|
||||||
14 . . . Assign: -
|
|
||||||
15 . . . Type: *ast.Ident {
|
|
||||||
16 . . . . NamePos: -
|
|
||||||
17 . . . . Name: "string"
|
|
||||||
18 . . . . Obj: nil
|
|
||||||
19 . . . }
|
|
||||||
20 . . . Comment: nil
|
|
||||||
21 . . }
|
|
||||||
22 . . Data: nil
|
|
||||||
23 . . Type: nil
|
|
||||||
24 . }
|
|
||||||
25 }
|
|
||||||
, payload 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Hash computes a hash of the payload using the specified algorithm.
|
|
||||||
|
|
||||||
- `Luhn(payload 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "bool"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Luhn validates a number using the Luhn algorithm.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `Register(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initializes its core.Runtime field.
|
|
||||||
|
|
||||||
- `TestHash(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
||||||
- `TestLuhn(t 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "testing"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "T"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) `:
|
|
||||||
|
|
|
||||||
|
|
@ -3,633 +3,54 @@ title: display
|
||||||
---
|
---
|
||||||
# Service: `display`
|
# Service: `display`
|
||||||
|
|
||||||
|
The `display` service manages the application's GUI windows, dialogs, and system tray interactions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
### `type ActionOpenWindow`
|
### `type ActionOpenWindow`
|
||||||
|
|
||||||
|
`ActionOpenWindow` is an IPC message used to request the creation of a new window.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type ActionOpenWindow 0 *ast.StructType {
|
type ActionOpenWindow struct {
|
||||||
1 . Struct: -
|
application.WebviewWindowOptions
|
||||||
2 . Fields: *ast.FieldList {
|
}
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 1) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.SelectorExpr {
|
|
||||||
9 . . . . . X: *ast.Ident {
|
|
||||||
10 . . . . . . NamePos: -
|
|
||||||
11 . . . . . . Name: "application"
|
|
||||||
12 . . . . . . Obj: nil
|
|
||||||
13 . . . . . }
|
|
||||||
14 . . . . . Sel: *ast.Ident {
|
|
||||||
15 . . . . . . NamePos: -
|
|
||||||
16 . . . . . . Name: "WebviewWindowOptions"
|
|
||||||
17 . . . . . . Obj: nil
|
|
||||||
18 . . . . . }
|
|
||||||
19 . . . . }
|
|
||||||
20 . . . . Tag: nil
|
|
||||||
21 . . . . Comment: nil
|
|
||||||
22 . . . }
|
|
||||||
23 . . }
|
|
||||||
24 . . Closing: -
|
|
||||||
25 . }
|
|
||||||
26 . Incomplete: false
|
|
||||||
27 }
|
|
||||||
|
|
||||||
```
|
```
|
||||||
ActionOpenWindow is an IPC message used to request a new window.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type Options`
|
|
||||||
```go
|
|
||||||
type Options 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: nil
|
|
||||||
5 . . Closing: -
|
|
||||||
6 . }
|
|
||||||
7 . Incomplete: false
|
|
||||||
8 }
|
|
||||||
|
|
||||||
```
|
|
||||||
Options holds configuration for the display service.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type Service`
|
|
||||||
```go
|
|
||||||
type Service 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 2) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.StarExpr {
|
|
||||||
9 . . . . . Star: -
|
|
||||||
10 . . . . . X: *ast.IndexExpr {
|
|
||||||
11 . . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . . Name: "core"
|
|
||||||
15 . . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . . }
|
|
||||||
17 . . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . . Name: "Runtime"
|
|
||||||
20 . . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . . }
|
|
||||||
22 . . . . . . }
|
|
||||||
23 . . . . . . Lbrack: -
|
|
||||||
24 . . . . . . Index: *ast.Ident {
|
|
||||||
25 . . . . . . . NamePos: -
|
|
||||||
26 . . . . . . . Name: "Options"
|
|
||||||
27 . . . . . . . Obj: *ast.Object {
|
|
||||||
28 . . . . . . . . Kind: type
|
|
||||||
29 . . . . . . . . Name: "Options"
|
|
||||||
30 . . . . . . . . Decl: *ast.TypeSpec {
|
|
||||||
31 . . . . . . . . . Doc: nil
|
|
||||||
32 . . . . . . . . . Name: *ast.Ident {
|
|
||||||
33 . . . . . . . . . . NamePos: -
|
|
||||||
34 . . . . . . . . . . Name: "Options"
|
|
||||||
35 . . . . . . . . . . Obj: *(obj @ 27)
|
|
||||||
36 . . . . . . . . . }
|
|
||||||
37 . . . . . . . . . TypeParams: nil
|
|
||||||
38 . . . . . . . . . Assign: -
|
|
||||||
39 . . . . . . . . . Type: *ast.StructType {
|
|
||||||
40 . . . . . . . . . . Struct: -
|
|
||||||
41 . . . . . . . . . . Fields: *ast.FieldList {
|
|
||||||
42 . . . . . . . . . . . Opening: -
|
|
||||||
43 . . . . . . . . . . . List: nil
|
|
||||||
44 . . . . . . . . . . . Closing: -
|
|
||||||
45 . . . . . . . . . . }
|
|
||||||
46 . . . . . . . . . . Incomplete: false
|
|
||||||
47 . . . . . . . . . }
|
|
||||||
48 . . . . . . . . . Comment: nil
|
|
||||||
49 . . . . . . . . }
|
|
||||||
50 . . . . . . . . Data: nil
|
|
||||||
51 . . . . . . . . Type: nil
|
|
||||||
52 . . . . . . . }
|
|
||||||
53 . . . . . . }
|
|
||||||
54 . . . . . . Rbrack: -
|
|
||||||
55 . . . . . }
|
|
||||||
56 . . . . }
|
|
||||||
57 . . . . Tag: nil
|
|
||||||
58 . . . . Comment: nil
|
|
||||||
59 . . . }
|
|
||||||
60 . . . 1: *ast.Field {
|
|
||||||
61 . . . . Doc: nil
|
|
||||||
62 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
63 . . . . . 0: *ast.Ident {
|
|
||||||
64 . . . . . . NamePos: -
|
|
||||||
65 . . . . . . Name: "config"
|
|
||||||
66 . . . . . . Obj: *ast.Object {
|
|
||||||
67 . . . . . . . Kind: var
|
|
||||||
68 . . . . . . . Name: "config"
|
|
||||||
69 . . . . . . . Decl: *(obj @ 60)
|
|
||||||
70 . . . . . . . Data: nil
|
|
||||||
71 . . . . . . . Type: nil
|
|
||||||
72 . . . . . . }
|
|
||||||
73 . . . . . }
|
|
||||||
74 . . . . }
|
|
||||||
75 . . . . Type: *ast.SelectorExpr {
|
|
||||||
76 . . . . . X: *ast.Ident {
|
|
||||||
77 . . . . . . NamePos: -
|
|
||||||
78 . . . . . . Name: "core"
|
|
||||||
79 . . . . . . Obj: nil
|
|
||||||
80 . . . . . }
|
|
||||||
81 . . . . . Sel: *ast.Ident {
|
|
||||||
82 . . . . . . NamePos: -
|
|
||||||
83 . . . . . . Name: "Config"
|
|
||||||
84 . . . . . . Obj: nil
|
|
||||||
85 . . . . . }
|
|
||||||
86 . . . . }
|
|
||||||
87 . . . . Tag: nil
|
|
||||||
88 . . . . Comment: nil
|
|
||||||
89 . . . }
|
|
||||||
90 . . }
|
|
||||||
91 . . Closing: -
|
|
||||||
92 . }
|
|
||||||
93 . Incomplete: false
|
|
||||||
94 }
|
|
||||||
|
|
||||||
```
|
|
||||||
Service manages windowing, dialogs, and other visual elements.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Methods
|
|
||||||
|
|
||||||
- `HandleIPCEvents(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, msg 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "core"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Message"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: HandleIPCEvents processes IPC messages and performs actions such as opening windows or initializing services based on message types.
|
|
||||||
|
|
||||||
- `NewWithOptions(opts 0 *ast.Ellipsis {
|
|
||||||
1 . Ellipsis: -
|
|
||||||
2 . Elt: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "WindowOption"
|
|
||||||
5 . . Obj: *ast.Object {
|
|
||||||
6 . . . Kind: type
|
|
||||||
7 . . . Name: "WindowOption"
|
|
||||||
8 . . . Decl: *ast.TypeSpec {
|
|
||||||
9 . . . . Doc: nil
|
|
||||||
10 . . . . Name: *ast.Ident {
|
|
||||||
11 . . . . . NamePos: -
|
|
||||||
12 . . . . . Name: "WindowOption"
|
|
||||||
13 . . . . . Obj: *(obj @ 5)
|
|
||||||
14 . . . . }
|
|
||||||
15 . . . . TypeParams: nil
|
|
||||||
16 . . . . Assign: -
|
|
||||||
17 . . . . Type: *ast.FuncType {
|
|
||||||
18 . . . . . Func: -
|
|
||||||
19 . . . . . TypeParams: nil
|
|
||||||
20 . . . . . Params: *ast.FieldList {
|
|
||||||
21 . . . . . . Opening: -
|
|
||||||
22 . . . . . . List: []*ast.Field (len = 1) {
|
|
||||||
23 . . . . . . . 0: *ast.Field {
|
|
||||||
24 . . . . . . . . Doc: nil
|
|
||||||
25 . . . . . . . . Names: nil
|
|
||||||
26 . . . . . . . . Type: *ast.StarExpr {
|
|
||||||
27 . . . . . . . . . Star: -
|
|
||||||
28 . . . . . . . . . X: *ast.SelectorExpr {
|
|
||||||
29 . . . . . . . . . . X: *ast.Ident {
|
|
||||||
30 . . . . . . . . . . . NamePos: -
|
|
||||||
31 . . . . . . . . . . . Name: "application"
|
|
||||||
32 . . . . . . . . . . . Obj: nil
|
|
||||||
33 . . . . . . . . . . }
|
|
||||||
34 . . . . . . . . . . Sel: *ast.Ident {
|
|
||||||
35 . . . . . . . . . . . NamePos: -
|
|
||||||
36 . . . . . . . . . . . Name: "WebviewWindowOptions"
|
|
||||||
37 . . . . . . . . . . . Obj: nil
|
|
||||||
38 . . . . . . . . . . }
|
|
||||||
39 . . . . . . . . . }
|
|
||||||
40 . . . . . . . . }
|
|
||||||
41 . . . . . . . . Tag: nil
|
|
||||||
42 . . . . . . . . Comment: nil
|
|
||||||
43 . . . . . . . }
|
|
||||||
44 . . . . . . }
|
|
||||||
45 . . . . . . Closing: -
|
|
||||||
46 . . . . . }
|
|
||||||
47 . . . . . Results: *ast.FieldList {
|
|
||||||
48 . . . . . . Opening: -
|
|
||||||
49 . . . . . . List: []*ast.Field (len = 1) {
|
|
||||||
50 . . . . . . . 0: *ast.Field {
|
|
||||||
51 . . . . . . . . Doc: nil
|
|
||||||
52 . . . . . . . . Names: nil
|
|
||||||
53 . . . . . . . . Type: *ast.Ident {
|
|
||||||
54 . . . . . . . . . NamePos: -
|
|
||||||
55 . . . . . . . . . Name: "error"
|
|
||||||
56 . . . . . . . . . Obj: nil
|
|
||||||
57 . . . . . . . . }
|
|
||||||
58 . . . . . . . . Tag: nil
|
|
||||||
59 . . . . . . . . Comment: nil
|
|
||||||
60 . . . . . . . }
|
|
||||||
61 . . . . . . }
|
|
||||||
62 . . . . . . Closing: -
|
|
||||||
63 . . . . . }
|
|
||||||
64 . . . . }
|
|
||||||
65 . . . . Comment: nil
|
|
||||||
66 . . . }
|
|
||||||
67 . . . Data: nil
|
|
||||||
68 . . . Type: nil
|
|
||||||
69 . . }
|
|
||||||
70 . }
|
|
||||||
71 }
|
|
||||||
) 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "application"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "WebviewWindow"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: NewWithOptions creates a new window by applying a series of options.
|
|
||||||
|
|
||||||
- `NewWithStruct(options 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "Window"
|
|
||||||
5 . . Obj: *ast.Object {
|
|
||||||
6 . . . Kind: type
|
|
||||||
7 . . . Name: "Window"
|
|
||||||
8 . . . Decl: *ast.TypeSpec {
|
|
||||||
9 . . . . Doc: nil
|
|
||||||
10 . . . . Name: *ast.Ident {
|
|
||||||
11 . . . . . NamePos: -
|
|
||||||
12 . . . . . Name: "Window"
|
|
||||||
13 . . . . . Obj: *(obj @ 5)
|
|
||||||
14 . . . . }
|
|
||||||
15 . . . . TypeParams: nil
|
|
||||||
16 . . . . Assign: -
|
|
||||||
17 . . . . Type: *ast.SelectorExpr {
|
|
||||||
18 . . . . . X: *ast.Ident {
|
|
||||||
19 . . . . . . NamePos: -
|
|
||||||
20 . . . . . . Name: "application"
|
|
||||||
21 . . . . . . Obj: nil
|
|
||||||
22 . . . . . }
|
|
||||||
23 . . . . . Sel: *ast.Ident {
|
|
||||||
24 . . . . . . NamePos: -
|
|
||||||
25 . . . . . . Name: "WebviewWindowOptions"
|
|
||||||
26 . . . . . . Obj: nil
|
|
||||||
27 . . . . . }
|
|
||||||
28 . . . . }
|
|
||||||
29 . . . . Comment: nil
|
|
||||||
30 . . . }
|
|
||||||
31 . . . Data: nil
|
|
||||||
32 . . . Type: nil
|
|
||||||
33 . . }
|
|
||||||
34 . }
|
|
||||||
35 }
|
|
||||||
) 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "application"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "WebviewWindow"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: NewWithStruct creates a new window using the provided options and returns its handle.
|
|
||||||
|
|
||||||
- `NewWithURL(url 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "application"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "WebviewWindow"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: NewWithURL creates a new default window pointing to the specified URL.
|
|
||||||
|
|
||||||
- `OpenWindow(opts 0 *ast.Ellipsis {
|
|
||||||
1 . Ellipsis: -
|
|
||||||
2 . Elt: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "WindowOption"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: OpenWindow creates a new window with the default options.
|
|
||||||
|
|
||||||
- `SelectDirectory() 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: SelectDirectory opens a directory selection dialog and returns the selected path.
|
|
||||||
|
|
||||||
- `ServiceName() 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`:
|
|
||||||
|
|
||||||
- `ServiceStartup( 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "context"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Context"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
, 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "application"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "ServiceOptions"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: ServiceStartup initializes the display service and sets up the main application window and system tray.
|
|
||||||
|
|
||||||
- `ShowEnvironmentDialog() `: ShowEnvironmentDialog displays a dialog containing detailed information about the application's runtime environment.
|
|
||||||
|
|
||||||
- `Window() 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "Window"
|
|
||||||
5 . . Obj: *ast.Object {
|
|
||||||
6 . . . Kind: type
|
|
||||||
7 . . . Name: "Window"
|
|
||||||
8 . . . Decl: *ast.TypeSpec {
|
|
||||||
9 . . . . Doc: nil
|
|
||||||
10 . . . . Name: *ast.Ident {
|
|
||||||
11 . . . . . NamePos: -
|
|
||||||
12 . . . . . Name: "Window"
|
|
||||||
13 . . . . . Obj: *(obj @ 5)
|
|
||||||
14 . . . . }
|
|
||||||
15 . . . . TypeParams: nil
|
|
||||||
16 . . . . Assign: -
|
|
||||||
17 . . . . Type: *ast.SelectorExpr {
|
|
||||||
18 . . . . . X: *ast.Ident {
|
|
||||||
19 . . . . . . NamePos: -
|
|
||||||
20 . . . . . . Name: "application"
|
|
||||||
21 . . . . . . Obj: nil
|
|
||||||
22 . . . . . }
|
|
||||||
23 . . . . . Sel: *ast.Ident {
|
|
||||||
24 . . . . . . NamePos: -
|
|
||||||
25 . . . . . . Name: "WebviewWindowOptions"
|
|
||||||
26 . . . . . . Obj: nil
|
|
||||||
27 . . . . . }
|
|
||||||
28 . . . . }
|
|
||||||
29 . . . . Comment: nil
|
|
||||||
30 . . . }
|
|
||||||
31 . . . Data: nil
|
|
||||||
32 . . . Type: nil
|
|
||||||
33 . . }
|
|
||||||
34 . }
|
|
||||||
35 }
|
|
||||||
`:
|
|
||||||
|
|
||||||
- `buildMenu() `: buildMenu creates and sets the main application menu.
|
|
||||||
|
|
||||||
- `handleOpenWindowAction(msg 0 *ast.MapType {
|
|
||||||
1 . Map: -
|
|
||||||
2 . Key: *ast.Ident {
|
|
||||||
3 . . NamePos: -
|
|
||||||
4 . . Name: "string"
|
|
||||||
5 . . Obj: nil
|
|
||||||
6 . }
|
|
||||||
7 . Value: *ast.Ident {
|
|
||||||
8 . . NamePos: -
|
|
||||||
9 . . Name: "any"
|
|
||||||
10 . . Obj: nil
|
|
||||||
11 . }
|
|
||||||
12 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: handleOpenWindowAction processes a message to configure and create a new window using specified name and options.
|
|
||||||
|
|
||||||
- `monitorScreenChanges() `: monitorScreenChanges listens for theme change events and logs when screen configuration changes occur.
|
|
||||||
|
|
||||||
- `systemTray() `: setupTray configures and creates the system tray icon and menu.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type Window`
|
|
||||||
```go
|
|
||||||
type Window 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "application"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "WebviewWindowOptions"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type WindowOption`
|
### `type WindowOption`
|
||||||
```go
|
|
||||||
type WindowOption 0 *ast.FuncType {
|
|
||||||
1 . Func: -
|
|
||||||
2 . TypeParams: nil
|
|
||||||
3 . Params: *ast.FieldList {
|
|
||||||
4 . . Opening: -
|
|
||||||
5 . . List: []*ast.Field (len = 1) {
|
|
||||||
6 . . . 0: *ast.Field {
|
|
||||||
7 . . . . Doc: nil
|
|
||||||
8 . . . . Names: nil
|
|
||||||
9 . . . . Type: *ast.StarExpr {
|
|
||||||
10 . . . . . Star: -
|
|
||||||
11 . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . Name: "application"
|
|
||||||
15 . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . }
|
|
||||||
17 . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . Name: "WebviewWindowOptions"
|
|
||||||
20 . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . }
|
|
||||||
22 . . . . . }
|
|
||||||
23 . . . . }
|
|
||||||
24 . . . . Tag: nil
|
|
||||||
25 . . . . Comment: nil
|
|
||||||
26 . . . }
|
|
||||||
27 . . }
|
|
||||||
28 . . Closing: -
|
|
||||||
29 . }
|
|
||||||
30 . Results: *ast.FieldList {
|
|
||||||
31 . . Opening: -
|
|
||||||
32 . . List: []*ast.Field (len = 1) {
|
|
||||||
33 . . . 0: *ast.Field {
|
|
||||||
34 . . . . Doc: nil
|
|
||||||
35 . . . . Names: nil
|
|
||||||
36 . . . . Type: *ast.Ident {
|
|
||||||
37 . . . . . NamePos: -
|
|
||||||
38 . . . . . Name: "error"
|
|
||||||
39 . . . . . Obj: nil
|
|
||||||
40 . . . . }
|
|
||||||
41 . . . . Tag: nil
|
|
||||||
42 . . . . Comment: nil
|
|
||||||
43 . . . }
|
|
||||||
44 . . }
|
|
||||||
45 . . Closing: -
|
|
||||||
46 . }
|
|
||||||
47 }
|
|
||||||
|
|
||||||
|
`WindowOption` is a functional option type for configuring a window during creation.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type WindowOption func(*application.WebviewWindowOptions) error
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### `func OpenWindow(opts ...WindowOption) error`
|
||||||
|
|
||||||
|
`OpenWindow` creates and shows a new window with the specified options.
|
||||||
|
|
||||||
|
### `func NewWithURL(url string) (*application.WebviewWindow, error)`
|
||||||
|
|
||||||
|
`NewWithURL` creates a new window pointing to the specified URL using default settings.
|
||||||
|
|
||||||
|
### `func NewWithOptions(opts ...WindowOption) (*application.WebviewWindow, error)`
|
||||||
|
|
||||||
## Functions
|
`NewWithOptions` creates a new window by applying a series of `WindowOption` functions.
|
||||||
|
|
||||||
- `Register(c 0 *ast.StarExpr {
|
### `func SelectDirectory() (string, error)`
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
`SelectDirectory` opens a native directory selection dialog and returns the selected path.
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
### `func ShowEnvironmentDialog()`
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
`ShowEnvironmentDialog` displays a dialog containing detailed information about the application's runtime environment (OS, version, etc.).
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
### `func ServiceStartup(ctx context.Context, options application.ServiceOptions) error`
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
`ServiceStartup` initializes the display service, setting up the main window, menu, and system tray.
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
### `func HandleIPCEvents(c *core.Core, msg core.Message) error`
|
||||||
13 . }
|
|
||||||
14 }
|
`HandleIPCEvents` processes display-related IPC messages, such as `ActionOpenWindow`.
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initializes its core.Runtime field.
|
|
||||||
|
|
|
||||||
|
|
@ -3,310 +3,18 @@ title: help
|
||||||
---
|
---
|
||||||
# Service: `help`
|
# Service: `help`
|
||||||
|
|
||||||
|
The `help` service manages the in-app documentation and help system, allowing users to view guides and context-sensitive help.
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### `func Show() error`
|
||||||
|
|
||||||
|
`Show` opens the main help window or interface.
|
||||||
|
|
||||||
|
### `func ShowAt(anchor string) error`
|
||||||
|
|
||||||
## Types
|
`ShowAt` opens the help window and navigates directly to the section specified by the `anchor`.
|
||||||
|
|
||||||
### `type Options`
|
### `func HandleIPCEvents(c *core.Core, msg core.Message) error`
|
||||||
```go
|
|
||||||
type Options 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: nil
|
|
||||||
5 . . Closing: -
|
|
||||||
6 . }
|
|
||||||
7 . Incomplete: false
|
|
||||||
8 }
|
|
||||||
|
|
||||||
```
|
`HandleIPCEvents` processes help-related IPC messages, allowing other services to trigger help displays.
|
||||||
Options holds configuration for the help service.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type Service`
|
|
||||||
```go
|
|
||||||
type Service 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 4) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.StarExpr {
|
|
||||||
9 . . . . . Star: -
|
|
||||||
10 . . . . . X: *ast.IndexExpr {
|
|
||||||
11 . . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . . Name: "core"
|
|
||||||
15 . . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . . }
|
|
||||||
17 . . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . . Name: "Runtime"
|
|
||||||
20 . . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . . }
|
|
||||||
22 . . . . . . }
|
|
||||||
23 . . . . . . Lbrack: -
|
|
||||||
24 . . . . . . Index: *ast.Ident {
|
|
||||||
25 . . . . . . . NamePos: -
|
|
||||||
26 . . . . . . . Name: "Options"
|
|
||||||
27 . . . . . . . Obj: *ast.Object {
|
|
||||||
28 . . . . . . . . Kind: type
|
|
||||||
29 . . . . . . . . Name: "Options"
|
|
||||||
30 . . . . . . . . Decl: *ast.TypeSpec {
|
|
||||||
31 . . . . . . . . . Doc: nil
|
|
||||||
32 . . . . . . . . . Name: *ast.Ident {
|
|
||||||
33 . . . . . . . . . . NamePos: -
|
|
||||||
34 . . . . . . . . . . Name: "Options"
|
|
||||||
35 . . . . . . . . . . Obj: *(obj @ 27)
|
|
||||||
36 . . . . . . . . . }
|
|
||||||
37 . . . . . . . . . TypeParams: nil
|
|
||||||
38 . . . . . . . . . Assign: -
|
|
||||||
39 . . . . . . . . . Type: *ast.StructType {
|
|
||||||
40 . . . . . . . . . . Struct: -
|
|
||||||
41 . . . . . . . . . . Fields: *ast.FieldList {
|
|
||||||
42 . . . . . . . . . . . Opening: -
|
|
||||||
43 . . . . . . . . . . . List: nil
|
|
||||||
44 . . . . . . . . . . . Closing: -
|
|
||||||
45 . . . . . . . . . . }
|
|
||||||
46 . . . . . . . . . . Incomplete: false
|
|
||||||
47 . . . . . . . . . }
|
|
||||||
48 . . . . . . . . . Comment: nil
|
|
||||||
49 . . . . . . . . }
|
|
||||||
50 . . . . . . . . Data: nil
|
|
||||||
51 . . . . . . . . Type: nil
|
|
||||||
52 . . . . . . . }
|
|
||||||
53 . . . . . . }
|
|
||||||
54 . . . . . . Rbrack: -
|
|
||||||
55 . . . . . }
|
|
||||||
56 . . . . }
|
|
||||||
57 . . . . Tag: nil
|
|
||||||
58 . . . . Comment: nil
|
|
||||||
59 . . . }
|
|
||||||
60 . . . 1: *ast.Field {
|
|
||||||
61 . . . . Doc: nil
|
|
||||||
62 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
63 . . . . . 0: *ast.Ident {
|
|
||||||
64 . . . . . . NamePos: -
|
|
||||||
65 . . . . . . Name: "config"
|
|
||||||
66 . . . . . . Obj: *ast.Object {
|
|
||||||
67 . . . . . . . Kind: var
|
|
||||||
68 . . . . . . . Name: "config"
|
|
||||||
69 . . . . . . . Decl: *(obj @ 60)
|
|
||||||
70 . . . . . . . Data: nil
|
|
||||||
71 . . . . . . . Type: nil
|
|
||||||
72 . . . . . . }
|
|
||||||
73 . . . . . }
|
|
||||||
74 . . . . }
|
|
||||||
75 . . . . Type: *ast.SelectorExpr {
|
|
||||||
76 . . . . . X: *ast.Ident {
|
|
||||||
77 . . . . . . NamePos: -
|
|
||||||
78 . . . . . . Name: "core"
|
|
||||||
79 . . . . . . Obj: nil
|
|
||||||
80 . . . . . }
|
|
||||||
81 . . . . . Sel: *ast.Ident {
|
|
||||||
82 . . . . . . NamePos: -
|
|
||||||
83 . . . . . . Name: "Config"
|
|
||||||
84 . . . . . . Obj: nil
|
|
||||||
85 . . . . . }
|
|
||||||
86 . . . . }
|
|
||||||
87 . . . . Tag: nil
|
|
||||||
88 . . . . Comment: nil
|
|
||||||
89 . . . }
|
|
||||||
90 . . . 2: *ast.Field {
|
|
||||||
91 . . . . Doc: nil
|
|
||||||
92 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
93 . . . . . 0: *ast.Ident {
|
|
||||||
94 . . . . . . NamePos: -
|
|
||||||
95 . . . . . . Name: "display"
|
|
||||||
96 . . . . . . Obj: *ast.Object {
|
|
||||||
97 . . . . . . . Kind: var
|
|
||||||
98 . . . . . . . Name: "display"
|
|
||||||
99 . . . . . . . Decl: *(obj @ 90)
|
|
||||||
100 . . . . . . . Data: nil
|
|
||||||
101 . . . . . . . Type: nil
|
|
||||||
102 . . . . . . }
|
|
||||||
103 . . . . . }
|
|
||||||
104 . . . . }
|
|
||||||
105 . . . . Type: *ast.SelectorExpr {
|
|
||||||
106 . . . . . X: *ast.Ident {
|
|
||||||
107 . . . . . . NamePos: -
|
|
||||||
108 . . . . . . Name: "core"
|
|
||||||
109 . . . . . . Obj: nil
|
|
||||||
110 . . . . . }
|
|
||||||
111 . . . . . Sel: *ast.Ident {
|
|
||||||
112 . . . . . . NamePos: -
|
|
||||||
113 . . . . . . Name: "Display"
|
|
||||||
114 . . . . . . Obj: nil
|
|
||||||
115 . . . . . }
|
|
||||||
116 . . . . }
|
|
||||||
117 . . . . Tag: nil
|
|
||||||
118 . . . . Comment: nil
|
|
||||||
119 . . . }
|
|
||||||
120 . . . 3: *ast.Field {
|
|
||||||
121 . . . . Doc: nil
|
|
||||||
122 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
123 . . . . . 0: *ast.Ident {
|
|
||||||
124 . . . . . . NamePos: -
|
|
||||||
125 . . . . . . Name: "assets"
|
|
||||||
126 . . . . . . Obj: *ast.Object {
|
|
||||||
127 . . . . . . . Kind: var
|
|
||||||
128 . . . . . . . Name: "assets"
|
|
||||||
129 . . . . . . . Decl: *(obj @ 120)
|
|
||||||
130 . . . . . . . Data: nil
|
|
||||||
131 . . . . . . . Type: nil
|
|
||||||
132 . . . . . . }
|
|
||||||
133 . . . . . }
|
|
||||||
134 . . . . }
|
|
||||||
135 . . . . Type: *ast.SelectorExpr {
|
|
||||||
136 . . . . . X: *ast.Ident {
|
|
||||||
137 . . . . . . NamePos: -
|
|
||||||
138 . . . . . . Name: "embed"
|
|
||||||
139 . . . . . . Obj: nil
|
|
||||||
140 . . . . . }
|
|
||||||
141 . . . . . Sel: *ast.Ident {
|
|
||||||
142 . . . . . . NamePos: -
|
|
||||||
143 . . . . . . Name: "FS"
|
|
||||||
144 . . . . . . Obj: nil
|
|
||||||
145 . . . . . }
|
|
||||||
146 . . . . }
|
|
||||||
147 . . . . Tag: nil
|
|
||||||
148 . . . . Comment: nil
|
|
||||||
149 . . . }
|
|
||||||
150 . . }
|
|
||||||
151 . . Closing: -
|
|
||||||
152 . }
|
|
||||||
153 . Incomplete: false
|
|
||||||
154 }
|
|
||||||
|
|
||||||
```
|
|
||||||
Service manages the in-app help system.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Methods
|
|
||||||
|
|
||||||
- `HandleIPCEvents(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, msg 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "core"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Message"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: HandleIPCEvents processes IPC messages, including injecting dependencies on startup.
|
|
||||||
|
|
||||||
- `ServiceStartup( 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "context"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Context"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
, 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "application"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "ServiceOptions"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: ServiceStartup is called when the app starts, after dependencies are injected.
|
|
||||||
|
|
||||||
- `Show() 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Show displays the help window.
|
|
||||||
|
|
||||||
- `ShowAt(anchor 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: ShowAt displays a specific section of the help documentation.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `Register(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initialises its core.Runtime field. Dependencies are injected during ServiceStartup.
|
|
||||||
|
|
|
||||||
|
|
@ -3,376 +3,22 @@ title: i18n
|
||||||
---
|
---
|
||||||
# Service: `i18n`
|
# Service: `i18n`
|
||||||
|
|
||||||
|
The `i18n` service handles internationalization and localization, allowing the application to support multiple languages.
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### `func SetLanguage(lang string) error`
|
||||||
|
|
||||||
|
`SetLanguage` sets the active application language. It loads the appropriate message bundle for the specified language tag (e.g., "en-US", "fr").
|
||||||
|
|
||||||
|
### `func Translate(messageID string) string`
|
||||||
|
|
||||||
## Types
|
`Translate` retrieves the localized string for the given `messageID` in the current active language. If no translation is found, it may return the ID or a fallback.
|
||||||
|
|
||||||
### `type Options`
|
### `func HandleIPCEvents(c *core.Core, msg core.Message) error`
|
||||||
```go
|
|
||||||
type Options 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: nil
|
|
||||||
5 . . Closing: -
|
|
||||||
6 . }
|
|
||||||
7 . Incomplete: false
|
|
||||||
8 }
|
|
||||||
|
|
||||||
```
|
`HandleIPCEvents` handles IPC messages related to language changes or translation requests.
|
||||||
Options holds configuration for the i18n service.
|
|
||||||
|
|
||||||
|
### `func ServiceStartup(ctx context.Context, options application.ServiceOptions) error`
|
||||||
|
|
||||||
|
`ServiceStartup` initializes the i18n service, loading available languages and setting the default locale.
|
||||||
|
|
||||||
|
|
||||||
### `type Service`
|
|
||||||
```go
|
|
||||||
type Service 0 *ast.StructType {
|
|
||||||
1 . Struct: -
|
|
||||||
2 . Fields: *ast.FieldList {
|
|
||||||
3 . . Opening: -
|
|
||||||
4 . . List: []*ast.Field (len = 4) {
|
|
||||||
5 . . . 0: *ast.Field {
|
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: nil
|
|
||||||
8 . . . . Type: *ast.StarExpr {
|
|
||||||
9 . . . . . Star: -
|
|
||||||
10 . . . . . X: *ast.IndexExpr {
|
|
||||||
11 . . . . . . X: *ast.SelectorExpr {
|
|
||||||
12 . . . . . . . X: *ast.Ident {
|
|
||||||
13 . . . . . . . . NamePos: -
|
|
||||||
14 . . . . . . . . Name: "core"
|
|
||||||
15 . . . . . . . . Obj: nil
|
|
||||||
16 . . . . . . . }
|
|
||||||
17 . . . . . . . Sel: *ast.Ident {
|
|
||||||
18 . . . . . . . . NamePos: -
|
|
||||||
19 . . . . . . . . Name: "Runtime"
|
|
||||||
20 . . . . . . . . Obj: nil
|
|
||||||
21 . . . . . . . }
|
|
||||||
22 . . . . . . }
|
|
||||||
23 . . . . . . Lbrack: -
|
|
||||||
24 . . . . . . Index: *ast.Ident {
|
|
||||||
25 . . . . . . . NamePos: -
|
|
||||||
26 . . . . . . . Name: "Options"
|
|
||||||
27 . . . . . . . Obj: *ast.Object {
|
|
||||||
28 . . . . . . . . Kind: type
|
|
||||||
29 . . . . . . . . Name: "Options"
|
|
||||||
30 . . . . . . . . Decl: *ast.TypeSpec {
|
|
||||||
31 . . . . . . . . . Doc: nil
|
|
||||||
32 . . . . . . . . . Name: *ast.Ident {
|
|
||||||
33 . . . . . . . . . . NamePos: -
|
|
||||||
34 . . . . . . . . . . Name: "Options"
|
|
||||||
35 . . . . . . . . . . Obj: *(obj @ 27)
|
|
||||||
36 . . . . . . . . . }
|
|
||||||
37 . . . . . . . . . TypeParams: nil
|
|
||||||
38 . . . . . . . . . Assign: -
|
|
||||||
39 . . . . . . . . . Type: *ast.StructType {
|
|
||||||
40 . . . . . . . . . . Struct: -
|
|
||||||
41 . . . . . . . . . . Fields: *ast.FieldList {
|
|
||||||
42 . . . . . . . . . . . Opening: -
|
|
||||||
43 . . . . . . . . . . . List: nil
|
|
||||||
44 . . . . . . . . . . . Closing: -
|
|
||||||
45 . . . . . . . . . . }
|
|
||||||
46 . . . . . . . . . . Incomplete: false
|
|
||||||
47 . . . . . . . . . }
|
|
||||||
48 . . . . . . . . . Comment: nil
|
|
||||||
49 . . . . . . . . }
|
|
||||||
50 . . . . . . . . Data: nil
|
|
||||||
51 . . . . . . . . Type: nil
|
|
||||||
52 . . . . . . . }
|
|
||||||
53 . . . . . . }
|
|
||||||
54 . . . . . . Rbrack: -
|
|
||||||
55 . . . . . }
|
|
||||||
56 . . . . }
|
|
||||||
57 . . . . Tag: nil
|
|
||||||
58 . . . . Comment: nil
|
|
||||||
59 . . . }
|
|
||||||
60 . . . 1: *ast.Field {
|
|
||||||
61 . . . . Doc: nil
|
|
||||||
62 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
63 . . . . . 0: *ast.Ident {
|
|
||||||
64 . . . . . . NamePos: -
|
|
||||||
65 . . . . . . Name: "bundle"
|
|
||||||
66 . . . . . . Obj: *ast.Object {
|
|
||||||
67 . . . . . . . Kind: var
|
|
||||||
68 . . . . . . . Name: "bundle"
|
|
||||||
69 . . . . . . . Decl: *(obj @ 60)
|
|
||||||
70 . . . . . . . Data: nil
|
|
||||||
71 . . . . . . . Type: nil
|
|
||||||
72 . . . . . . }
|
|
||||||
73 . . . . . }
|
|
||||||
74 . . . . }
|
|
||||||
75 . . . . Type: *ast.StarExpr {
|
|
||||||
76 . . . . . Star: -
|
|
||||||
77 . . . . . X: *ast.SelectorExpr {
|
|
||||||
78 . . . . . . X: *ast.Ident {
|
|
||||||
79 . . . . . . . NamePos: -
|
|
||||||
80 . . . . . . . Name: "i18n"
|
|
||||||
81 . . . . . . . Obj: nil
|
|
||||||
82 . . . . . . }
|
|
||||||
83 . . . . . . Sel: *ast.Ident {
|
|
||||||
84 . . . . . . . NamePos: -
|
|
||||||
85 . . . . . . . Name: "Bundle"
|
|
||||||
86 . . . . . . . Obj: nil
|
|
||||||
87 . . . . . . }
|
|
||||||
88 . . . . . }
|
|
||||||
89 . . . . }
|
|
||||||
90 . . . . Tag: nil
|
|
||||||
91 . . . . Comment: nil
|
|
||||||
92 . . . }
|
|
||||||
93 . . . 2: *ast.Field {
|
|
||||||
94 . . . . Doc: nil
|
|
||||||
95 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
96 . . . . . 0: *ast.Ident {
|
|
||||||
97 . . . . . . NamePos: -
|
|
||||||
98 . . . . . . Name: "localizer"
|
|
||||||
99 . . . . . . Obj: *ast.Object {
|
|
||||||
100 . . . . . . . Kind: var
|
|
||||||
101 . . . . . . . Name: "localizer"
|
|
||||||
102 . . . . . . . Decl: *(obj @ 93)
|
|
||||||
103 . . . . . . . Data: nil
|
|
||||||
104 . . . . . . . Type: nil
|
|
||||||
105 . . . . . . }
|
|
||||||
106 . . . . . }
|
|
||||||
107 . . . . }
|
|
||||||
108 . . . . Type: *ast.StarExpr {
|
|
||||||
109 . . . . . Star: -
|
|
||||||
110 . . . . . X: *ast.SelectorExpr {
|
|
||||||
111 . . . . . . X: *ast.Ident {
|
|
||||||
112 . . . . . . . NamePos: -
|
|
||||||
113 . . . . . . . Name: "i18n"
|
|
||||||
114 . . . . . . . Obj: nil
|
|
||||||
115 . . . . . . }
|
|
||||||
116 . . . . . . Sel: *ast.Ident {
|
|
||||||
117 . . . . . . . NamePos: -
|
|
||||||
118 . . . . . . . Name: "Localizer"
|
|
||||||
119 . . . . . . . Obj: nil
|
|
||||||
120 . . . . . . }
|
|
||||||
121 . . . . . }
|
|
||||||
122 . . . . }
|
|
||||||
123 . . . . Tag: nil
|
|
||||||
124 . . . . Comment: nil
|
|
||||||
125 . . . }
|
|
||||||
126 . . . 3: *ast.Field {
|
|
||||||
127 . . . . Doc: nil
|
|
||||||
128 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
129 . . . . . 0: *ast.Ident {
|
|
||||||
130 . . . . . . NamePos: -
|
|
||||||
131 . . . . . . Name: "availableLangs"
|
|
||||||
132 . . . . . . Obj: *ast.Object {
|
|
||||||
133 . . . . . . . Kind: var
|
|
||||||
134 . . . . . . . Name: "availableLangs"
|
|
||||||
135 . . . . . . . Decl: *(obj @ 126)
|
|
||||||
136 . . . . . . . Data: nil
|
|
||||||
137 . . . . . . . Type: nil
|
|
||||||
138 . . . . . . }
|
|
||||||
139 . . . . . }
|
|
||||||
140 . . . . }
|
|
||||||
141 . . . . Type: *ast.ArrayType {
|
|
||||||
142 . . . . . Lbrack: -
|
|
||||||
143 . . . . . Len: nil
|
|
||||||
144 . . . . . Elt: *ast.SelectorExpr {
|
|
||||||
145 . . . . . . X: *ast.Ident {
|
|
||||||
146 . . . . . . . NamePos: -
|
|
||||||
147 . . . . . . . Name: "language"
|
|
||||||
148 . . . . . . . Obj: nil
|
|
||||||
149 . . . . . . }
|
|
||||||
150 . . . . . . Sel: *ast.Ident {
|
|
||||||
151 . . . . . . . NamePos: -
|
|
||||||
152 . . . . . . . Name: "Tag"
|
|
||||||
153 . . . . . . . Obj: nil
|
|
||||||
154 . . . . . . }
|
|
||||||
155 . . . . . }
|
|
||||||
156 . . . . }
|
|
||||||
157 . . . . Tag: nil
|
|
||||||
158 . . . . Comment: nil
|
|
||||||
159 . . . }
|
|
||||||
160 . . }
|
|
||||||
161 . . Closing: -
|
|
||||||
162 . }
|
|
||||||
163 . Incomplete: false
|
|
||||||
164 }
|
|
||||||
|
|
||||||
```
|
|
||||||
Service provides internationalization and localization.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Methods
|
|
||||||
|
|
||||||
- `HandleIPCEvents(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
, msg 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "core"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Message"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: HandleIPCEvents processes IPC messages, including injecting dependencies on startup.
|
|
||||||
|
|
||||||
- `ServiceStartup( 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "context"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Context"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
, 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "application"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "ServiceOptions"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: ServiceStartup is called when the app starts, after dependencies are injected.
|
|
||||||
|
|
||||||
- `SetLanguage(lang 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`:
|
|
||||||
|
|
||||||
- `Translate(messageID 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
- `Register(c 0 *ast.StarExpr {
|
|
||||||
1 . Star: -
|
|
||||||
2 . X: *ast.SelectorExpr {
|
|
||||||
3 . . X: *ast.Ident {
|
|
||||||
4 . . . NamePos: -
|
|
||||||
5 . . . Name: "core"
|
|
||||||
6 . . . Obj: nil
|
|
||||||
7 . . }
|
|
||||||
8 . . Sel: *ast.Ident {
|
|
||||||
9 . . . NamePos: -
|
|
||||||
10 . . . Name: "Core"
|
|
||||||
11 . . . Obj: nil
|
|
||||||
12 . . }
|
|
||||||
13 . }
|
|
||||||
14 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "any"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initializes its core.Runtime field. Dependencies are injected during ServiceStartup.
|
|
||||||
|
|
||||||
- `detectLanguage(supported 0 *ast.ArrayType {
|
|
||||||
1 . Lbrack: -
|
|
||||||
2 . Len: nil
|
|
||||||
3 . Elt: *ast.SelectorExpr {
|
|
||||||
4 . . X: *ast.Ident {
|
|
||||||
5 . . . NamePos: -
|
|
||||||
6 . . . Name: "language"
|
|
||||||
7 . . . Obj: nil
|
|
||||||
8 . . }
|
|
||||||
9 . . Sel: *ast.Ident {
|
|
||||||
10 . . . NamePos: -
|
|
||||||
11 . . . Name: "Tag"
|
|
||||||
12 . . . Obj: nil
|
|
||||||
13 . . }
|
|
||||||
14 . }
|
|
||||||
15 }
|
|
||||||
) 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "string"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`:
|
|
||||||
|
|
||||||
- `getAvailableLanguages() 0 *ast.ArrayType {
|
|
||||||
1 . Lbrack: -
|
|
||||||
2 . Len: nil
|
|
||||||
3 . Elt: *ast.SelectorExpr {
|
|
||||||
4 . . X: *ast.Ident {
|
|
||||||
5 . . . NamePos: -
|
|
||||||
6 . . . Name: "language"
|
|
||||||
7 . . . Obj: nil
|
|
||||||
8 . . }
|
|
||||||
9 . . Sel: *ast.Ident {
|
|
||||||
10 . . . NamePos: -
|
|
||||||
11 . . . Name: "Tag"
|
|
||||||
12 . . . Obj: nil
|
|
||||||
13 . . }
|
|
||||||
14 . }
|
|
||||||
15 }
|
|
||||||
, 0 *ast.Ident {
|
|
||||||
1 . NamePos: -
|
|
||||||
2 . Name: "error"
|
|
||||||
3 . Obj: nil
|
|
||||||
4 }
|
|
||||||
`:
|
|
||||||
|
|
|
||||||
|
|
@ -3,386 +3,74 @@ title: runtime
|
||||||
---
|
---
|
||||||
# Service: `runtime`
|
# Service: `runtime`
|
||||||
|
|
||||||
|
The `runtime` service provides the main entry point for the application and a helper structure for services to interact with the `Core`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
### `type Runtime`
|
### `type Runtime`
|
||||||
|
|
||||||
|
`Runtime` is the top-level container that holds the `Core` instance and the Wails application. It serves as the bridge between Wails and the Core framework.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type Runtime 0 *ast.StructType {
|
type Runtime struct {
|
||||||
1 . Struct: -
|
// Core is the central service manager
|
||||||
2 . Fields: *ast.FieldList {
|
Core *Core
|
||||||
3 . . Opening: -
|
// app is the Wails application instance
|
||||||
4 . . List: []*ast.Field (len = 8) {
|
app *application.App
|
||||||
5 . . . 0: *ast.Field {
|
}
|
||||||
6 . . . . Doc: nil
|
|
||||||
7 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
8 . . . . . 0: *ast.Ident {
|
|
||||||
9 . . . . . . NamePos: -
|
|
||||||
10 . . . . . . Name: "app"
|
|
||||||
11 . . . . . . Obj: *ast.Object {
|
|
||||||
12 . . . . . . . Kind: var
|
|
||||||
13 . . . . . . . Name: "app"
|
|
||||||
14 . . . . . . . Decl: *(obj @ 5)
|
|
||||||
15 . . . . . . . Data: nil
|
|
||||||
16 . . . . . . . Type: nil
|
|
||||||
17 . . . . . . }
|
|
||||||
18 . . . . . }
|
|
||||||
19 . . . . }
|
|
||||||
20 . . . . Type: *ast.StarExpr {
|
|
||||||
21 . . . . . Star: -
|
|
||||||
22 . . . . . X: *ast.SelectorExpr {
|
|
||||||
23 . . . . . . X: *ast.Ident {
|
|
||||||
24 . . . . . . . NamePos: -
|
|
||||||
25 . . . . . . . Name: "application"
|
|
||||||
26 . . . . . . . Obj: nil
|
|
||||||
27 . . . . . . }
|
|
||||||
28 . . . . . . Sel: *ast.Ident {
|
|
||||||
29 . . . . . . . NamePos: -
|
|
||||||
30 . . . . . . . Name: "App"
|
|
||||||
31 . . . . . . . Obj: nil
|
|
||||||
32 . . . . . . }
|
|
||||||
33 . . . . . }
|
|
||||||
34 . . . . }
|
|
||||||
35 . . . . Tag: nil
|
|
||||||
36 . . . . Comment: nil
|
|
||||||
37 . . . }
|
|
||||||
38 . . . 1: *ast.Field {
|
|
||||||
39 . . . . Doc: nil
|
|
||||||
40 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
41 . . . . . 0: *ast.Ident {
|
|
||||||
42 . . . . . . NamePos: -
|
|
||||||
43 . . . . . . Name: "Core"
|
|
||||||
44 . . . . . . Obj: *ast.Object {
|
|
||||||
45 . . . . . . . Kind: var
|
|
||||||
46 . . . . . . . Name: "Core"
|
|
||||||
47 . . . . . . . Decl: *(obj @ 38)
|
|
||||||
48 . . . . . . . Data: nil
|
|
||||||
49 . . . . . . . Type: nil
|
|
||||||
50 . . . . . . }
|
|
||||||
51 . . . . . }
|
|
||||||
52 . . . . }
|
|
||||||
53 . . . . Type: *ast.StarExpr {
|
|
||||||
54 . . . . . Star: -
|
|
||||||
55 . . . . . X: *ast.SelectorExpr {
|
|
||||||
56 . . . . . . X: *ast.Ident {
|
|
||||||
57 . . . . . . . NamePos: -
|
|
||||||
58 . . . . . . . Name: "core"
|
|
||||||
59 . . . . . . . Obj: nil
|
|
||||||
60 . . . . . . }
|
|
||||||
61 . . . . . . Sel: *ast.Ident {
|
|
||||||
62 . . . . . . . NamePos: -
|
|
||||||
63 . . . . . . . Name: "Core"
|
|
||||||
64 . . . . . . . Obj: nil
|
|
||||||
65 . . . . . . }
|
|
||||||
66 . . . . . }
|
|
||||||
67 . . . . }
|
|
||||||
68 . . . . Tag: nil
|
|
||||||
69 . . . . Comment: nil
|
|
||||||
70 . . . }
|
|
||||||
71 . . . 2: *ast.Field {
|
|
||||||
72 . . . . Doc: nil
|
|
||||||
73 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
74 . . . . . 0: *ast.Ident {
|
|
||||||
75 . . . . . . NamePos: -
|
|
||||||
76 . . . . . . Name: "Config"
|
|
||||||
77 . . . . . . Obj: *ast.Object {
|
|
||||||
78 . . . . . . . Kind: var
|
|
||||||
79 . . . . . . . Name: "Config"
|
|
||||||
80 . . . . . . . Decl: *(obj @ 71)
|
|
||||||
81 . . . . . . . Data: nil
|
|
||||||
82 . . . . . . . Type: nil
|
|
||||||
83 . . . . . . }
|
|
||||||
84 . . . . . }
|
|
||||||
85 . . . . }
|
|
||||||
86 . . . . Type: *ast.StarExpr {
|
|
||||||
87 . . . . . Star: -
|
|
||||||
88 . . . . . X: *ast.SelectorExpr {
|
|
||||||
89 . . . . . . X: *ast.Ident {
|
|
||||||
90 . . . . . . . NamePos: -
|
|
||||||
91 . . . . . . . Name: "config"
|
|
||||||
92 . . . . . . . Obj: nil
|
|
||||||
93 . . . . . . }
|
|
||||||
94 . . . . . . Sel: *ast.Ident {
|
|
||||||
95 . . . . . . . NamePos: -
|
|
||||||
96 . . . . . . . Name: "Service"
|
|
||||||
97 . . . . . . . Obj: nil
|
|
||||||
98 . . . . . . }
|
|
||||||
99 . . . . . }
|
|
||||||
100 . . . . }
|
|
||||||
101 . . . . Tag: nil
|
|
||||||
102 . . . . Comment: nil
|
|
||||||
103 . . . }
|
|
||||||
104 . . . 3: *ast.Field {
|
|
||||||
105 . . . . Doc: nil
|
|
||||||
106 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
107 . . . . . 0: *ast.Ident {
|
|
||||||
108 . . . . . . NamePos: -
|
|
||||||
109 . . . . . . Name: "Display"
|
|
||||||
110 . . . . . . Obj: *ast.Object {
|
|
||||||
111 . . . . . . . Kind: var
|
|
||||||
112 . . . . . . . Name: "Display"
|
|
||||||
113 . . . . . . . Decl: *(obj @ 104)
|
|
||||||
114 . . . . . . . Data: nil
|
|
||||||
115 . . . . . . . Type: nil
|
|
||||||
116 . . . . . . }
|
|
||||||
117 . . . . . }
|
|
||||||
118 . . . . }
|
|
||||||
119 . . . . Type: *ast.StarExpr {
|
|
||||||
120 . . . . . Star: -
|
|
||||||
121 . . . . . X: *ast.SelectorExpr {
|
|
||||||
122 . . . . . . X: *ast.Ident {
|
|
||||||
123 . . . . . . . NamePos: -
|
|
||||||
124 . . . . . . . Name: "display"
|
|
||||||
125 . . . . . . . Obj: nil
|
|
||||||
126 . . . . . . }
|
|
||||||
127 . . . . . . Sel: *ast.Ident {
|
|
||||||
128 . . . . . . . NamePos: -
|
|
||||||
129 . . . . . . . Name: "Service"
|
|
||||||
130 . . . . . . . Obj: nil
|
|
||||||
131 . . . . . . }
|
|
||||||
132 . . . . . }
|
|
||||||
133 . . . . }
|
|
||||||
134 . . . . Tag: nil
|
|
||||||
135 . . . . Comment: nil
|
|
||||||
136 . . . }
|
|
||||||
137 . . . 4: *ast.Field {
|
|
||||||
138 . . . . Doc: nil
|
|
||||||
139 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
140 . . . . . 0: *ast.Ident {
|
|
||||||
141 . . . . . . NamePos: -
|
|
||||||
142 . . . . . . Name: "Help"
|
|
||||||
143 . . . . . . Obj: *ast.Object {
|
|
||||||
144 . . . . . . . Kind: var
|
|
||||||
145 . . . . . . . Name: "Help"
|
|
||||||
146 . . . . . . . Decl: *(obj @ 137)
|
|
||||||
147 . . . . . . . Data: nil
|
|
||||||
148 . . . . . . . Type: nil
|
|
||||||
149 . . . . . . }
|
|
||||||
150 . . . . . }
|
|
||||||
151 . . . . }
|
|
||||||
152 . . . . Type: *ast.StarExpr {
|
|
||||||
153 . . . . . Star: -
|
|
||||||
154 . . . . . X: *ast.SelectorExpr {
|
|
||||||
155 . . . . . . X: *ast.Ident {
|
|
||||||
156 . . . . . . . NamePos: -
|
|
||||||
157 . . . . . . . Name: "help"
|
|
||||||
158 . . . . . . . Obj: nil
|
|
||||||
159 . . . . . . }
|
|
||||||
160 . . . . . . Sel: *ast.Ident {
|
|
||||||
161 . . . . . . . NamePos: -
|
|
||||||
162 . . . . . . . Name: "Service"
|
|
||||||
163 . . . . . . . Obj: nil
|
|
||||||
164 . . . . . . }
|
|
||||||
165 . . . . . }
|
|
||||||
166 . . . . }
|
|
||||||
167 . . . . Tag: nil
|
|
||||||
168 . . . . Comment: nil
|
|
||||||
169 . . . }
|
|
||||||
170 . . . 5: *ast.Field {
|
|
||||||
171 . . . . Doc: nil
|
|
||||||
172 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
173 . . . . . 0: *ast.Ident {
|
|
||||||
174 . . . . . . NamePos: -
|
|
||||||
175 . . . . . . Name: "Crypt"
|
|
||||||
176 . . . . . . Obj: *ast.Object {
|
|
||||||
177 . . . . . . . Kind: var
|
|
||||||
178 . . . . . . . Name: "Crypt"
|
|
||||||
179 . . . . . . . Decl: *(obj @ 170)
|
|
||||||
180 . . . . . . . Data: nil
|
|
||||||
181 . . . . . . . Type: nil
|
|
||||||
182 . . . . . . }
|
|
||||||
183 . . . . . }
|
|
||||||
184 . . . . }
|
|
||||||
185 . . . . Type: *ast.StarExpr {
|
|
||||||
186 . . . . . Star: -
|
|
||||||
187 . . . . . X: *ast.SelectorExpr {
|
|
||||||
188 . . . . . . X: *ast.Ident {
|
|
||||||
189 . . . . . . . NamePos: -
|
|
||||||
190 . . . . . . . Name: "crypt"
|
|
||||||
191 . . . . . . . Obj: nil
|
|
||||||
192 . . . . . . }
|
|
||||||
193 . . . . . . Sel: *ast.Ident {
|
|
||||||
194 . . . . . . . NamePos: -
|
|
||||||
195 . . . . . . . Name: "Service"
|
|
||||||
196 . . . . . . . Obj: nil
|
|
||||||
197 . . . . . . }
|
|
||||||
198 . . . . . }
|
|
||||||
199 . . . . }
|
|
||||||
200 . . . . Tag: nil
|
|
||||||
201 . . . . Comment: nil
|
|
||||||
202 . . . }
|
|
||||||
203 . . . 6: *ast.Field {
|
|
||||||
204 . . . . Doc: nil
|
|
||||||
205 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
206 . . . . . 0: *ast.Ident {
|
|
||||||
207 . . . . . . NamePos: -
|
|
||||||
208 . . . . . . Name: "I18n"
|
|
||||||
209 . . . . . . Obj: *ast.Object {
|
|
||||||
210 . . . . . . . Kind: var
|
|
||||||
211 . . . . . . . Name: "I18n"
|
|
||||||
212 . . . . . . . Decl: *(obj @ 203)
|
|
||||||
213 . . . . . . . Data: nil
|
|
||||||
214 . . . . . . . Type: nil
|
|
||||||
215 . . . . . . }
|
|
||||||
216 . . . . . }
|
|
||||||
217 . . . . }
|
|
||||||
218 . . . . Type: *ast.StarExpr {
|
|
||||||
219 . . . . . Star: -
|
|
||||||
220 . . . . . X: *ast.SelectorExpr {
|
|
||||||
221 . . . . . . X: *ast.Ident {
|
|
||||||
222 . . . . . . . NamePos: -
|
|
||||||
223 . . . . . . . Name: "i18n"
|
|
||||||
224 . . . . . . . Obj: nil
|
|
||||||
225 . . . . . . }
|
|
||||||
226 . . . . . . Sel: *ast.Ident {
|
|
||||||
227 . . . . . . . NamePos: -
|
|
||||||
228 . . . . . . . Name: "Service"
|
|
||||||
229 . . . . . . . Obj: nil
|
|
||||||
230 . . . . . . }
|
|
||||||
231 . . . . . }
|
|
||||||
232 . . . . }
|
|
||||||
233 . . . . Tag: nil
|
|
||||||
234 . . . . Comment: nil
|
|
||||||
235 . . . }
|
|
||||||
236 . . . 7: *ast.Field {
|
|
||||||
237 . . . . Doc: nil
|
|
||||||
238 . . . . Names: []*ast.Ident (len = 1) {
|
|
||||||
239 . . . . . 0: *ast.Ident {
|
|
||||||
240 . . . . . . NamePos: -
|
|
||||||
241 . . . . . . Name: "Workspace"
|
|
||||||
242 . . . . . . Obj: *ast.Object {
|
|
||||||
243 . . . . . . . Kind: var
|
|
||||||
244 . . . . . . . Name: "Workspace"
|
|
||||||
245 . . . . . . . Decl: *(obj @ 236)
|
|
||||||
246 . . . . . . . Data: nil
|
|
||||||
247 . . . . . . . Type: nil
|
|
||||||
248 . . . . . . }
|
|
||||||
249 . . . . . }
|
|
||||||
250 . . . . }
|
|
||||||
251 . . . . Type: *ast.StarExpr {
|
|
||||||
252 . . . . . Star: -
|
|
||||||
253 . . . . . X: *ast.SelectorExpr {
|
|
||||||
254 . . . . . . X: *ast.Ident {
|
|
||||||
255 . . . . . . . NamePos: -
|
|
||||||
256 . . . . . . . Name: "workspace"
|
|
||||||
257 . . . . . . . Obj: nil
|
|
||||||
258 . . . . . . }
|
|
||||||
259 . . . . . . Sel: *ast.Ident {
|
|
||||||
260 . . . . . . . NamePos: -
|
|
||||||
261 . . . . . . . Name: "Service"
|
|
||||||
262 . . . . . . . Obj: nil
|
|
||||||
263 . . . . . . }
|
|
||||||
264 . . . . . }
|
|
||||||
265 . . . . }
|
|
||||||
266 . . . . Tag: nil
|
|
||||||
267 . . . . Comment: nil
|
|
||||||
268 . . . }
|
|
||||||
269 . . }
|
|
||||||
270 . . Closing: -
|
|
||||||
271 . }
|
|
||||||
272 . Incomplete: false
|
|
||||||
273 }
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Runtime is the container that holds all instantiated services.
|
|
||||||
Its fields are the concrete types, allowing Wails to bind them directly.
|
|
||||||
|
|
||||||
|
### `type ServiceRuntime[T any]`
|
||||||
|
|
||||||
|
`ServiceRuntime` is a generic helper struct designed to be embedded in service implementations. It provides easy access to the `Core` and service-specific options.
|
||||||
|
|
||||||
#### Methods
|
```go
|
||||||
|
type ServiceRuntime[T any] struct {
|
||||||
- `ServiceName() 0 *ast.Ident {
|
core *Core
|
||||||
1 . NamePos: -
|
opts T
|
||||||
2 . Name: "string"
|
}
|
||||||
3 . Obj: nil
|
```
|
||||||
4 }
|
|
||||||
`: ServiceName returns the name of the service. This is used by Wails to identify the service.
|
|
||||||
|
|
||||||
- `ServiceShutdown(ctx 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "context"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Context"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) `: ServiceShutdown is called by Wails at application shutdown.
|
|
||||||
|
|
||||||
- `ServiceStartup(ctx 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "context"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "Context"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
, options 0 *ast.SelectorExpr {
|
|
||||||
1 . X: *ast.Ident {
|
|
||||||
2 . . NamePos: -
|
|
||||||
3 . . Name: "application"
|
|
||||||
4 . . Obj: nil
|
|
||||||
5 . }
|
|
||||||
6 . Sel: *ast.Ident {
|
|
||||||
7 . . NamePos: -
|
|
||||||
8 . . Name: "ServiceOptions"
|
|
||||||
9 . . Obj: nil
|
|
||||||
10 . }
|
|
||||||
11 }
|
|
||||||
) `: ServiceStartup is called by Wails at application startup.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `type ServiceFactory`
|
### `type ServiceFactory`
|
||||||
```go
|
|
||||||
type ServiceFactory 0 *ast.FuncType {
|
|
||||||
1 . Func: -
|
|
||||||
2 . TypeParams: nil
|
|
||||||
3 . Params: *ast.FieldList {
|
|
||||||
4 . . Opening: -
|
|
||||||
5 . . List: nil
|
|
||||||
6 . . Closing: -
|
|
||||||
7 . }
|
|
||||||
8 . Results: *ast.FieldList {
|
|
||||||
9 . . Opening: -
|
|
||||||
10 . . List: []*ast.Field (len = 2) {
|
|
||||||
11 . . . 0: *ast.Field {
|
|
||||||
12 . . . . Doc: nil
|
|
||||||
13 . . . . Names: nil
|
|
||||||
14 . . . . Type: *ast.Ident {
|
|
||||||
15 . . . . . NamePos: -
|
|
||||||
16 . . . . . Name: "any"
|
|
||||||
17 . . . . . Obj: nil
|
|
||||||
18 . . . . }
|
|
||||||
19 . . . . Tag: nil
|
|
||||||
20 . . . . Comment: nil
|
|
||||||
21 . . . }
|
|
||||||
22 . . . 1: *ast.Field {
|
|
||||||
23 . . . . Doc: nil
|
|
||||||
24 . . . . Names: nil
|
|
||||||
25 . . . . Type: *ast.Ident {
|
|
||||||
26 . . . . . NamePos: -
|
|
||||||
27 . . . . . Name: "error"
|
|
||||||
28 . . . . . Obj: nil
|
|
||||||
29 . . . . }
|
|
||||||
30 . . . . Tag: nil
|
|
||||||
31 . . . . Comment: nil
|
|
||||||
32 . . . }
|
|
||||||
33 . . }
|
|
||||||
34 . . Closing: -
|
|
||||||
35 . }
|
|
||||||
36 }
|
|
||||||
|
|
||||||
|
`ServiceFactory` is a function type that creates a service instance.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type ServiceFactory func() (any, error)
|
||||||
```
|
```
|
||||||
ServiceFactory defines a function that creates a service instance.
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
### `func NewRuntime(app *application.App) (*Runtime, error)`
|
||||||
|
|
||||||
|
`NewRuntime` creates and wires together all application services using default settings. It is the standard way to initialize the runtime.
|
||||||
|
|
||||||
|
### `func NewWithFactories(app *application.App, factories map[string]ServiceFactory) (*Runtime, error)`
|
||||||
|
|
||||||
|
`NewWithFactories` creates a new `Runtime` instance using a provided map of service factories. This allows for flexible, dynamic service registration.
|
||||||
|
|
||||||
|
### `func NewServiceRuntime[T any](c *Core, opts T) *ServiceRuntime[T]`
|
||||||
|
|
||||||
|
`NewServiceRuntime` creates a new `ServiceRuntime` instance. This is typically used in a service's factory or constructor.
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
### `func (r *Runtime) ServiceName() string`
|
||||||
|
|
||||||
|
`ServiceName` returns the name of the service ("Core"). This is used by Wails for service identification.
|
||||||
|
|
||||||
|
### `func (r *Runtime) ServiceStartup(ctx context.Context, options application.ServiceOptions)`
|
||||||
|
|
||||||
|
`ServiceStartup` delegates the startup lifecycle event to the underlying `Core`, which in turn initializes all registered services.
|
||||||
|
|
||||||
|
### `func (r *Runtime) ServiceShutdown(ctx context.Context)`
|
||||||
|
|
||||||
|
`ServiceShutdown` delegates the shutdown lifecycle event to the underlying `Core`.
|
||||||
|
|
||||||
|
### `func (r *ServiceRuntime[T]) Core() *Core`
|
||||||
|
|
||||||
|
`Core` returns the central `Core` instance, giving the service access to other services and features.
|
||||||
|
|
||||||
|
### `func (r *ServiceRuntime[T]) Config() Config`
|
||||||
|
|
||||||
|
`Config` returns the registered `Config` service from the `Core`. It is a convenience method for accessing configuration.
|
||||||
|
|
|
||||||
|
|
@ -3,47 +3,14 @@ title: workspace
|
||||||
---
|
---
|
||||||
# Service: `workspace`
|
# Service: `workspace`
|
||||||
|
|
||||||
## Constants
|
The `workspace` service manages user workspaces, which are isolated environments for user data and configuration.
|
||||||
|
|
||||||
```go
|
|
||||||
defaultWorkspacelistFile
|
|
||||||
```
|
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
### `type Options`
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Options struct {
|
|
||||||
// Options holds configuration for the workspace service.
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `type Service`
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Service struct {
|
|
||||||
core.Runtime[*Options]
|
|
||||||
activeWorkspace *Workspace
|
|
||||||
workspaceList map[string]string // Maps Workspace ID to Public Key
|
|
||||||
medium io.Medium
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Service manages user workspaces.
|
|
||||||
|
|
||||||
#### Methods
|
|
||||||
|
|
||||||
- `CreateWorkspace(identifier, password string) (string, error)`: CreateWorkspace creates a new, obfuscated workspace on the local medium.
|
|
||||||
- `HandleIPCEvents(c *core.Core, msg core.Message) error`: HandleIPCEvents processes IPC messages, including injecting dependencies on startup.
|
|
||||||
- `ServiceStartup(context.Context, application.ServiceOptions) error`: ServiceStartup initializes the service, loading the workspace list.
|
|
||||||
- `SwitchWorkspace(name string) error`: SwitchWorkspace changes the active workspace.
|
|
||||||
- `WorkspaceFileGet(filename string) (string, error)`: WorkspaceFileGet retrieves a file from the active workspace.
|
|
||||||
- `WorkspaceFileSet(filename, content string) error`: WorkspaceFileSet writes a file to the active workspace.
|
|
||||||
- `getWorkspaceDir() (string, error)`: getWorkspaceDir retrieves the WorkspaceDir from the config service.
|
|
||||||
|
|
||||||
### `type Workspace`
|
### `type Workspace`
|
||||||
|
|
||||||
|
`Workspace` represents a single user workspace.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
Name string
|
Name string
|
||||||
|
|
@ -51,26 +18,32 @@ type Workspace struct {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Workspace represents a user's workspace.
|
## Methods
|
||||||
|
|
||||||
### `type localMedium`
|
### `func CreateWorkspace(identifier, password string) (string, error)`
|
||||||
|
|
||||||
```go
|
`CreateWorkspace` creates a new, secure workspace.
|
||||||
type localMedium struct{}
|
- **identifier**: A unique name or ID for the workspace.
|
||||||
```
|
- **password**: A password used to secure the workspace (if encryption is supported).
|
||||||
|
|
||||||
localMedium implements the Medium interface for the local disk.
|
Returns the workspace ID or path.
|
||||||
|
|
||||||
#### Methods
|
### `func SwitchWorkspace(name string) error`
|
||||||
|
|
||||||
- `EnsureDir(path string) error`: EnsureDir creates a directory on the local disk.
|
`SwitchWorkspace` changes the currently active workspace to the one specified by `name`.
|
||||||
- `FileGet(path string) (string, error)`: FileGet reads a file from the local disk.
|
|
||||||
- `FileSet(path, content string) error`: FileSet writes a file to the local disk.
|
|
||||||
- `IsFile(path string) bool`: IsFile checks if a path exists and is a file on the local disk.
|
|
||||||
- `Read(path string) (string, error)`: Read reads a file from the local disk.
|
|
||||||
- `Write(path, content string) error`: Write writes a file to the local disk.
|
|
||||||
|
|
||||||
## Functions
|
### `func WorkspaceFileGet(filename string) (string, error)`
|
||||||
|
|
||||||
- `NewLocalMedium() io.Medium`: NewLocalMedium creates a new instance of the local storage medium.
|
`WorkspaceFileGet` retrieves the content of a file located within the active workspace.
|
||||||
- `Register(c *core.Core) (any, error)`: Register is the constructor for dynamic dependency injection (used with core.WithService). It creates a Service instance and initializes its core.Runtime field. Dependencies are injected during ServiceStartup.
|
|
||||||
|
### `func WorkspaceFileSet(filename, content string) error`
|
||||||
|
|
||||||
|
`WorkspaceFileSet` writes content to a file within the active workspace.
|
||||||
|
|
||||||
|
### `func HandleIPCEvents(c *core.Core, msg core.Message) error`
|
||||||
|
|
||||||
|
`HandleIPCEvents` processes workspace-related IPC messages.
|
||||||
|
|
||||||
|
### `func ServiceStartup(ctx context.Context, options application.ServiceOptions) error`
|
||||||
|
|
||||||
|
`ServiceStartup` initializes the workspace service and loads the list of available workspaces.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue