Skip to content

Commit 4c74801

Browse files
committed
docs(clash-core): add go install guide via apt
1 parent ea9aa17 commit 4c74801

15 files changed

+119
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Install Go via APT on Debian
3+
lang: en
4+
layout: post
5+
audio: false
6+
translated: false
7+
generated: true
8+
---
9+
10+
To install Go using `apt` on a Debian-based Linux system (e.g., Ubuntu), follow these steps. Note that `apt` may install an older version of Go (e.g., 1.18 on Ubuntu 22.04), so you should verify if it meets your project's requirements (check the `go.mod` file in `~/Projects/clash-core` for the required Go version).
11+
12+
### Steps to Install Go Using APT
13+
14+
1. **Update the Package Index**
15+
- Ensure your package lists are up to date:
16+
```bash
17+
sudo apt update
18+
```
19+
20+
2. **Install Go**
21+
- Install the Go package:
22+
```bash
23+
sudo apt install golang-go
24+
```
25+
- This installs the Go compiler, tools, and standard library.
26+
27+
3. **Verify the Installation**
28+
- Check the installed Go version:
29+
```bash
30+
go version
31+
```
32+
- You should see output like:
33+
```
34+
go version go1.18.1 linux/amd64
35+
```
36+
(The version depends on your distribution's package repository.)
37+
38+
4. **Set Up GOPATH (Optional)**
39+
- Modern Go versions (1.13+) use modules, so `GOPATH` is optional, but setting it can be useful for some projects.
40+
- Edit your shell profile (e.g., `~/.bashrc` or `~/.zshrc`):
41+
```bash
42+
nano ~/.bashrc
43+
```
44+
- Add the following:
45+
```bash
46+
export GOPATH=$HOME/go
47+
export PATH=$PATH:$GOPATH/bin
48+
```
49+
- Save and reload the shell configuration:
50+
```bash
51+
source ~/.bashrc
52+
```
53+
54+
5. **Retry the Build**
55+
- Navigate to your project directory:
56+
```bash
57+
cd ~/Projects/clash-core
58+
```
59+
- Run the `make` command again:
60+
```bash
61+
make
62+
```
63+
64+
### Notes
65+
- **Version Check**: If your project requires a newer Go version (e.g., 1.20 or later), the `apt` version might be outdated. Check the required version in `go.mod` or the project’s documentation. If needed, install a newer version manually by downloading the tarball from [https://go.dev/dl/](https://go.dev/dl/) (as described in the previous response).
66+
- **Alternative Repositories**: For a newer version via `apt`, you can add a third-party PPA (e.g., `ppa:longsleep/golang-backports` on Ubuntu). Run:
67+
```bash
68+
sudo add-apt-repository ppa:longsleep/golang-backports
69+
sudo apt update
70+
sudo apt install golang-go
71+
```
72+
- **Troubleshooting**:
73+
- If `go` is not found, ensure `/usr/bin/go` exists (`ls /usr/bin/go`). If not, reinstall with `sudo apt install --reinstall golang-go`.
74+
- If you get dependency errors, run `sudo apt install -f` to fix them.
75+
- For permission issues, ensure you have `sudo` privileges.
76+
77+
### Sources
78+
- Ubuntu Go installation guide: [https://ubuntu.com/server/docs/programming-go](https://ubuntu.com/server/docs/programming-go)
79+
- General apt usage: [https://help.ubuntu.com/community/AptGet/Howto](https://help.ubuntu.com/community/AptGet/Howto)
80+
81+
If the installed version is too old or you encounter issues, let me know your Linux distribution (e.g., Ubuntu 22.04) and the required Go version, and I’ll guide you further!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [signed-by=/usr/share/keyrings/cuda-F73B257B-keyring.gpg] file:///var/cuda-repo-ubuntu2204-12-2-local /
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main
2+
# deb-src https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main

scripts/apt-sources/github-cli.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [arch=amd64 signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
deb https://ppa.launchpadcontent.net/longsleep/golang-backports/ubuntu/ jammy main
2+
# deb-src https://ppa.launchpadcontent.net/longsleep/golang-backports/ubuntu/ jammy main

scripts/apt-sources/mozilla.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [signed-by=/usr/share/keyrings/nccl-local-F4B315EB-keyring.gpg] file:///var/nccl-local-repo-ubuntu2204-2.18.3-cuda12.2 /
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
deb https://ppa.launchpadcontent.net/openjdk-r/ppa/ubuntu/ jammy main
2+
# deb-src https://ppa.launchpadcontent.net/openjdk-r/ppa/ubuntu/ jammy main
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deb [arch=amd64 signed-by=/usr/share/keyrings/shiftkey-packages.gpg] https://apt.packages.shiftkey.dev/ubuntu/ any main

scripts/apt-sources/steam-beta.list

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Uncomment these lines to try the beta version of the Steam launcher
2+
#deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ beta steam
3+
#deb-src [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ beta steam

scripts/apt-sources/steam-stable.list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
2+
deb-src [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb https://esm.ubuntu.com/apps/ubuntu jammy-apps-security main
2+
# deb-src https://esm.ubuntu.com/apps/ubuntu jammy-apps-security main
3+
deb https://esm.ubuntu.com/apps/ubuntu jammy-apps-updates main
4+
# deb-src https://esm.ubuntu.com/apps/ubuntu jammy-apps-updates main
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb https://esm.ubuntu.com/infra/ubuntu jammy-infra-security main
2+
# deb-src https://esm.ubuntu.com/infra/ubuntu jammy-infra-security main
3+
deb https://esm.ubuntu.com/infra/ubuntu jammy-infra-updates main
4+
# deb-src https://esm.ubuntu.com/infra/ubuntu jammy-infra-updates main

scripts/sync/sync_apt_list.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
import shutil
3+
4+
src_dir = '/etc/apt/sources.list.d/'
5+
dst_dir = 'scripts/apt-sources'
6+
7+
os.makedirs(dst_dir, exist_ok=True)
8+
9+
for filename in os.listdir(src_dir):
10+
src_file = os.path.join(src_dir, filename)
11+
dst_file = os.path.join(dst_dir, filename)
12+
if os.path.isfile(src_file):
13+
shutil.copy2(src_file, dst_file)

0 commit comments

Comments
 (0)