b преди 5 месеца
родител
ревизия
2a37bcbcc9
променени са 4 файла, в които са добавени 154 реда и са изтрити 0 реда
  1. 66 0
      .devcontainer/devcontainer.json
  2. 3 0
      README.md
  3. 50 0
      _init/init
  4. 35 0
      docker-compose.yml

+ 66 - 0
.devcontainer/devcontainer.json

@@ -0,0 +1,66 @@
+// https://containers.dev/
+{
+  "name": "[ Golang 工具库 ]",
+  "service": "go_kit",
+  "dockerComposeFile": "../docker-compose.yml",
+  "workspaceFolder": "/workspace",
+  "shutdownAction": "none", // none,stopContainer,stopCompose
+  "postCreateCommand": "cd /workspace/_init && sh ./init",
+  "remoteEnv": {
+    "HTTP_PROXY": "http://host.docker.internal:7890",
+    "HTTPS_PROXY": "http://host.docker.internal:7890",
+    "NO_PROXY": "localhost,127.0.0.1,host.docker.internal"
+  },
+  "customizations": {
+    "vscode": {
+      "settings": {
+        // 禁用 SSL 验证(如果你在使用代理服务器时遇到证书问题)
+        "http.proxyStrictSSL": false,
+        // 从 http 和 https 位置提取 JSON 架构
+        "json.schemaDownload.enable": false,
+        // 设置 Markdown 文件使用默认编辑器打开
+        "workbench.editorAssociations": {
+          "*.md": "default",
+          "*.markdown": "default"
+        },
+        // 设置制表符宽度为 2 个空格
+        "editor.tabSize": 2,
+
+        // 设置 Go 语言格式化工具为 gofmt
+        "go.formatTool": "gofmt",
+        // 设置 Go 测试标志,禁用测试缓存
+        "go.testFlags": ["-count=1"]
+      },
+      "extensions": [
+        // AI 助手
+        "MarsCode.marscode-extension",
+
+        // GoLang
+        "golang.go",
+
+        // Database Client JDBC
+        "cweijan.dbclient-jdbc",
+        // MySQL Client
+        "cweijan.vscode-mysql-client2",
+        // MySQL语法高亮 & 代码片段
+        "zendobk.mysql",
+
+        // 在 VSCode 中显示 PDF 文件
+        "tomoki1207.pdf",
+        // Office Viewer
+        "cweijan.vscode-office",
+
+        // 快捷键绑定
+        "ms-vscode.sublime-keybindings",
+        // 多行文本对齐
+        "yo1dog.cursor-align",
+        // 文本互换
+        "davidmart.swap-word",
+        // Git Graph
+        "mhutchie.git-graph",
+        // .env 文件语法支持
+        "mikestead.dotenv"
+      ]
+    }
+  }
+}

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# go-kit
+
+Golang 工具库:

+ 50 - 0
_init/init

@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# 先克隆 shell-kit 仓库(如果不存在)
+if [ ! -d "/workspace/shell-kit" ]; then
+	echo "正在克隆 shell-kit 仓库..."
+	if git clone root@git.ooo.ink:root/shell-kit.git /workspace/shell-kit; then
+		echo "shell-kit 仓库克隆完成"
+	else
+		echo "错误:shell-kit 仓库克隆失败"
+		exit 1
+	fi
+else
+	echo "shell-kit 仓库已存在,跳过克隆"
+fi
+
+# 配置SSH服务
+if [ -f "/workspace/shell-kit/setup-ssh.sh" ]; then
+	echo "正在配置 SSH 服务..."
+	chmod +x /workspace/shell-kit/setup-ssh.sh
+	/workspace/shell-kit/setup-ssh.sh
+else
+	echo "警告:SSH 配置脚本不存在,跳过 SSH 配置"
+fi
+
+# 安装 trunk 工具并初始化
+if [ -f "/workspace/shell-kit/setup-trunk.sh" ]; then
+	echo "正在安装 trunk 工具并初始化..."
+	chmod +x /workspace/shell-kit/setup-trunk.sh
+	/workspace/shell-kit/setup-trunk.sh
+else
+	echo "警告:trunk 安装脚本不存在,跳过 trunk 安装和初始化"
+fi
+
+# 安装 gentool 工具
+if [ -f "/workspace/shell-kit/setup-gentool.sh" ]; then
+	echo "正在安装 gentool 工具..."
+	chmod +x /workspace/shell-kit/setup-gentool.sh
+	/workspace/shell-kit/setup-gentool.sh
+else
+	echo "警告:gentool 安装脚本不存在,跳过 gentool 安装"
+fi
+
+# 安装 MySQL CLI 工具
+if [ -f "/workspace/shell-kit/setup-mysql-cli.sh" ]; then
+	echo "正在安装 MySQL CLI 工具..."
+	chmod +x /workspace/shell-kit/setup-mysql-cli.sh
+	/workspace/shell-kit/setup-mysql-cli.sh
+else
+	echo "警告:MySQL CLI 安装脚本不存在,跳过 MySQL CLI 安装"
+fi

+ 35 - 0
docker-compose.yml

@@ -0,0 +1,35 @@
+# https://docs.docker.com/compose/compose-file/05-services/
+services:
+  # https://hub.docker.com/_/golang
+  go_kit:
+    ports:
+      - 0:80
+      - 0:22
+    image: golang:1.26.0
+    command: sleep infinity
+    working_dir: /workspace
+    volumes:
+      - .:/workspace
+      - ~/.ssh:/root/.ssh
+      - go:/go
+
+  gk_mysql:
+    ports:
+      - 0:3306
+    image: mysql:8.0.37
+    restart: unless-stopped
+    # NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
+    # (this is just an example, not intended to be a production configuration)
+    command: --default-authentication-plugin=mysql_native_password
+    environment:
+      MYSQL_ROOT_PASSWORD: root
+
+  gk_redis:
+    ports:
+      - 0:6379
+    # 默认密码为空
+    image: redis:7.2.5
+
+volumes:
+  go:
+    external: true