diff --git a/code/go-project/base-farmework/.idea/.gitignore b/code/go-project/base-farmework/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/code/go-project/base-farmework/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/code/go-project/base-farmework/.idea/base-farmework.iml b/code/go-project/base-farmework/.idea/base-farmework.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/code/go-project/base-farmework/.idea/base-farmework.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/code/go-project/base-farmework/.idea/modules.xml b/code/go-project/base-farmework/.idea/modules.xml new file mode 100644 index 00000000..76f5c7d8 --- /dev/null +++ b/code/go-project/base-farmework/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/code/go-project/base-farmework/.idea/vcs.xml b/code/go-project/base-farmework/.idea/vcs.xml new file mode 100644 index 00000000..c2365ab1 --- /dev/null +++ b/code/go-project/base-farmework/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/code/go-project/base-farmework/cmd/app/main.go b/code/go-project/base-farmework/cmd/app/main.go new file mode 100644 index 00000000..dc855e4e --- /dev/null +++ b/code/go-project/base-farmework/cmd/app/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func helloHandler(w http.ResponseWriter, r *http.Request) { + _, err := fmt.Fprintf(w, "Hello, world!") + if err != nil { + log.Printf("write response error: %v", err) + return + } +} + +func main() { + http.HandleFunc("/", helloHandler) + + err := http.ListenAndServe(":8081", nil) + + if err != nil { + log.Fatalf("server start failed: %v", err) + } +} diff --git a/code/go-project/base-farmework/go.mod b/code/go-project/base-farmework/go.mod new file mode 100644 index 00000000..7f4081a2 --- /dev/null +++ b/code/go-project/base-farmework/go.mod @@ -0,0 +1,3 @@ +module base-farmework + +go 1.24 diff --git a/notes/前端开发/https/nginx_https配置.md b/notes/前端开发/https/nginx_https配置.md index 6b569019..ee49e90e 100644 --- a/notes/前端开发/https/nginx_https配置.md +++ b/notes/前端开发/https/nginx_https配置.md @@ -1,12 +1,12 @@ -## mkcer (本地) +# mkcer (本地) -### 下载 +## 下载 下载地址:https://github.com/FiloSottile/mkcert/releases 根据系统下载即可 -### **安装** +## **安装** 打开 cmd 执行命令 @@ -22,7 +22,7 @@ mkcert-v1.4.4-windows-amd64.exe -install ![image-20250607143508023](./assets/nginx_https%E9%85%8D%E7%BD%AE/image-20250607143508023.png) -### 生成自签证书 +## 生成自签证书 执行命令 @@ -36,11 +36,11 @@ mkcert-v1.4.4-windows-amd64.exe localhost 127.0.0.1 ::1 192.168.1.131 这样就成功啦,然后生成的证书在 **mkcert-v1.4.4-windows-amd64.exe** 的同级目录下 -### 配置 nginx +## 配置 nginx 配置文件参考 -``` +```### #user nobody; worker_processes 1; @@ -95,3 +95,23 @@ http { } ``` +## 避免不安全提示 + +win10系统: + +```bash +certmgr /c /add "localhost+3.pem" /s root +``` + +win7系统: + +``` +set CUR_PATH=%CD% +certutil -addstore -f -enterprise -user root "ca.pem" +``` + + + +# openssl + +参考:https://xinyufeng.net/2024/08/16/%E5%9C%A8-Windows-%E4%B8%8A%E7%94%9F%E6%88%90%E6%9C%AC%E5%9C%B0-SSL-%E8%AF%81%E4%B9%A6%E5%B9%B6%E4%BD%BF%E7%94%A8-HTTPS-%E8%AE%BF%E9%97%AE%E6%9C%AC%E5%9C%B0-Nginx-%E6%9C%8D%E5%8A%A1%E5%99%A8/ diff --git a/notes/后端开发/golang/项目骨架.md b/notes/后端开发/golang/项目骨架.md new file mode 100644 index 00000000..c43d4424 --- /dev/null +++ b/notes/后端开发/golang/项目骨架.md @@ -0,0 +1,26 @@ +# 项目结构 + +``` +myapp/ +├── cmd/ # 启动程序的入口(main.go 通常放在这里) +│ └── myapp/ +│ └── main.go # 主程序入口 +│ +├── internal/ # 内部模块,不能被外部引入 +│ ├── app/ # 应用逻辑层(服务、用例) +│ ├── config/ # 配置读取相关逻辑(如viper/yaml/env) +│ ├── handler/ # HTTP handler(路由处理函数) +│ ├── repository/ # 数据访问层(如数据库、缓存) +│ ├── service/ # 业务逻辑层 +│ └── model/ # 实体结构体、DTO、表结构等 +│ +├── pkg/ # 可被外部引入的公共包 +│ ├── logger/ # 日志封装 +│ ├── utils/ # 工具函数 +│ └── middleware/ # HTTP中间件 +│ +├── go.mod # Go module 定义 +├── go.sum # Go module 校验文件 +└── README.md # 项目说明 +``` +