GoLang -T

go版本

go version

 go本地配置

go env

开启GOSUMDB

go env -w GO111MODULE=on

写入配置-设置代理

go env -w GOPROXY=https://goproxy.io,direct

 

 

 

 

初始化包管理模块

go mod init projectName

查看依赖版本

go list -m -versions -json github.com/gin-gonic/gin

解释依赖

go mod why

修改go.mod文件

go mod edit -go=1.16

打印模块依赖图

go mod graph

更新依赖

go get -u

清理依赖(删除多余的包)

go mod tidy

 清空缓存

go clean --modcache

 

 

 

安装依赖

go get pkg

指定依赖版本

go get pkg@version

卸载依赖

go clean --modcache

查看已安装包

 go list -m all

设置私有仓库,多个用逗号相隔

go env -w GOPRIVATE=*.lib.tencent.com

 

 

 

nginx配置

静态文件后缀模式

server {
    listen       80;
    server_name  goframe.org;

    access_log   /var/log/gf-app-access.log;
    error_log    /var/log/gf-app-error.log;

    location ~ .*\.(gif|jpg|jpeg|png|js|css|eot|ttf|woff|svg|otf)$ {
        access_log off;
        expires    1d;
        root       /var/www/gf-app/public;
        try_files  $uri @backend;
    }

    location / {
        try_files $uri @backend;
    }

    location @backend {
        proxy_pass                 http://127.0.0.1:8199;
        proxy_redirect             off;
        proxy_set_header           Host             $host;
        proxy_set_header           X-Real-IP        $remote_addr;
        proxy_set_header           X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

静态文件目录模式

server {
    listen       80;
    server_name  goframe.org;

    access_log   /var/log/gf-app-access.log;
    error_log    /var/log/gf-app-error.log;

    location ^~ /public {
        access_log off;
        expires    1d;
        root       /var/www/gf-app;
        try_files  $uri @backend;
    }

    location / {
        try_files $uri @backend;
    }

    location @backend {
        proxy_pass                 http://127.0.0.1:8199;
        proxy_redirect             off;
        proxy_set_header           Host             $host;
        proxy_set_header           X-Real-IP        $remote_addr;
        proxy_set_header           X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

 

posted @ 2022-07-17 18:00  悬剑丶  阅读(62)  评论(0编辑  收藏  举报