Skip to content

Commit eb63249

Browse files
committed
Update Go/golang Snapcraft quickstart tutorial to use core22 and solve issue #2
1 parent e4ac217 commit eb63249

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

snapcraft/how-to/go-applications/go-applications.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,39 @@ description: |
2222
feels welcome and included. woke is a text file analysis tool that finds
2323
places within your source code that contain non-inclusive language and
2424
suggests replacing them with more inclusive alternatives.
25-
version: git
26-
grade: stable
27-
base: core20
25+
adopt-info: woke
26+
base: core22
2827

2928
confinement: devmode
3029

30+
plugs:
31+
dot-config-woke:
32+
interface: personal-files
33+
read:
34+
- $HOME/.config/woke.yaml
35+
- $HOME/.config/woke.yml
36+
- $HOME/.woke.yaml
37+
- $HOME/.woke.yml
38+
3139
apps:
3240
woke:
3341
command: bin/woke
3442
plugs:
3543
- home
44+
- dot-config-woke
45+
- network
46+
- removable-media
47+
3648
parts:
3749
woke:
3850
plugin: go
39-
source-type: git
51+
build-snaps: [go/latest/stable]
4052
source: https://github.com/get-woke/woke
53+
source-type: git
54+
override-pull: |
55+
snapcraftctl pull
56+
snapcraftctl set-version \
57+
"$(git describe --long --tags --always --match=v*.*.* | sed 's/v//')"
4158
```
4259
4360
We'll break this file down into its components in the following sections.
@@ -58,14 +75,14 @@ description: |
5875
feels welcome and included. woke is a text file analysis tool that finds
5976
places within your source code that contain non-inclusive language and
6077
suggests replacing them with more inclusive alternatives.
61-
version: git
78+
adopt-info: woke
6279
```
6380

64-
The `name` must be unique in the Snap Store. Valid snap names consist of lower-case alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
81+
The `name` must be unique in the Snap Store. Valid snap names consist of lowercase alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
6582

66-
By specifying `git` for the version, the current git tag or commit will be used as the version string. Versions carry no semantic meaning in snaps.
83+
The `summary` cannot exceed 79 characters. You can use a chevron '>' in the `description` key to declare a multi-line description.
6784

68-
The `summary` can not exceed 79 characters. You can use a chevron '>' in the `description` key to declare a multi-line description.
85+
The `adopt-info: woke` indicates that the snap should use metadata from the part named `woke`. This means that Snapcraft will look within the source repository defined in the `woke` part to find and adopt specific metadata such as `version`.
6986

7087
### Base
7188

@@ -74,11 +91,11 @@ A base snap is a special kind of snap that provides a run-time environment
7491
alongside a minimal set of libraries that are common to most applications.
7592

7693
```yaml
77-
base: core20
94+
base: core22
7895
```
7996

80-
In this example, [core20](https://snapcraft.io/core20) is used as the base for snap building, and is based
81-
on [Ubuntu 20.04 LTS](http://releases.ubuntu.com/20.04/). See [Base snaps](/t/11198) for more details.
97+
In this example, [core22](https://snapcraft.io/core22) is used as the base for snap building, and is based
98+
on [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/). See [Base snaps](/t/11198) for more details.
8299

83100
### Security model
84101

@@ -117,19 +134,30 @@ we only need to use one part for the *woke* source code:
117134
parts:
118135
woke:
119136
plugin: go
120-
source-type: git
137+
build-snaps: [go/latest/stable]
121138
source: https://github.com/get-woke/woke
139+
source-type: git
140+
override-pull: |
141+
snapcraftctl pull
142+
snapcraftctl set-version \
143+
"$(git describe --long --tags --always --match=v*.*.* | sed 's/v//')"
122144
```
123145

124146
The `plugin` keyword is used to select a language or technology-specific
125147
plugin that knows how to perform the build steps for the project.
126148
In this example, the [go plugin](/t/7818) is used to
127149
automate the build of this project using the version of Go on the host system.
128150

151+
The `build-snaps` keyword specifies a list of snaps that should be available during the build process. Here, using `go/latest/stable` ensures that the latest stable version of the Go snap is available for building the snap package.
152+
129153
The `source` keyword points to the source code of the project, which
130154
can be a local directory or remote Git repository. In this case, it refers to
131155
the main project repository.
132156

157+
The `source-type` keyword indicates that the source is a git repository.
158+
159+
The `override-pull` keyword in the `snapcraft.yaml` file allows you to customize the actions taken during the pull step of the build process. The pull step is responsible for downloading or fetching the source code specified in the source key. By default, Snapcraft handles this step automatically, but `override-pull` lets you define your own commands to extend or replace this behavior. See [Override build steps](https://snapcraft.io/docs/overrides)for more details.
160+
133161
### Apps
134162

135163
Apps are the commands and services that the snap provides to users. Each key
@@ -156,7 +184,7 @@ to avoid naming conflicts between installed snaps. An example of this would be
156184

157185
The confinement of the snap, which was defined in the **Security model** section
158186
above, can be changed through a set of :term:`interfaces`. In this example,
159-
the `plugs` keyword is used to specify the interfaces that the snap needs
187+
the `plugs` keyword specifies the interfaces that the snap needs
160188
to access.
161189

162190
### Building the snap
@@ -219,7 +247,7 @@ $ sudo snap remove woke
219247

220248
## Publishing your snap
221249

222-
To share your snaps you need to publish them in the Snap Store. First, create an account on [the dashboard](https://dashboard.snapcraft.io/dev/account/). Here you can customise how your snaps are presented, review your uploads and control publishing.
250+
To share your snaps, you need to publish them in the Snap Store. First, create an account on [the dashboard](https://dashboard.snapcraft.io/dev/account/). Here you can customise how your snaps are presented, review your uploads, and control publishing.
223251

224252
You’ll need to choose a unique “developer namespace” as part of the account creation process. This name will be visible by users and associated with your published snaps.
225253

0 commit comments

Comments
 (0)