• 安装go-admin


    安装过程

    1.下载源码(https://github.com/golangpkg/go-admin)后编译

    执行编译命令

    go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

    出现错误:
    main.go:5:2: cannot find package "github.com/astaxie/beego" in any of:
    D:Gosrcgithub.comastaxieeego (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comastaxieeego (from $GOPATH)
    main.go:9:2: cannot find package "github.com/astaxie/beego/context" in any of:
    D:Gosrcgithub.comastaxieeegocontext (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comastaxieeegocontext (from $GOPATH)
    main.go:8:2: cannot find package "github.com/astaxie/beego/logs" in any of:
    D:Gosrcgithub.comastaxieeegologs (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comastaxieeegologs (from $GOPATH)
    main.go:7:2: cannot find package "github.com/astaxie/beego/orm" in any of:
    D:Gosrcgithub.comastaxieeegoorm (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comastaxieeegoorm (from $GOPATH)
    main.go:4:2: cannot find package "github.com/golangpkg/go-admin/routers" in any of:
    D:Gosrcgithub.comgolangpkggo-admin outers (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comgolangpkggo-admin outers (from $GOPATH)
    main.go:6:2: cannot find package "github.com/mattn/go-sqlite3" in any of:
    D:Gosrcgithub.commattngo-sqlite3 (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.commattngo-sqlite3 (from $GOPATH)

    安装beego包

    go get github.com/astaxie/beego
    go: missing Git command. See https://golang.org/s/gogetcmd
    package github.com/astaxie/beego: exec: "git": executable file not found in %PATH%

    解决办法:

    在环境变量中加入git的路径,如PATH中新增“D:Program FilesGitin“;重启cmd窗口

    cd $go_root_path

    git clone https://github.com.cnpmjs.org/protocolbuffers/protobuf-go.git

    将clone的目录和文件放到 D:Gosrcgoogle.golang.orgprotobuf 目录下

     

    go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

    D:github2020go-admin>go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

    提示错误信息:
    main.go:4:2: cannot find package "github.com/golangpkg/go-admin/routers" in any of:
    D:Gosrcgithub.comgolangpkggo-admin outers (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.comgolangpkggo-admin outers (from $GOPATH)
    main.go:6:2: no Go files in F:xiaofsrc_codegolangsrcgithub.commattngo-sqlite3
    F:xiaofsrc_codegolangsrcgithub.comastaxieeegoormorm_raw.go:23:2: cannot find package "github.com/pkg/errors" in any of:
    D:Gosrcgithub.compkgerrors (from $GOROOT)
    F:xiaofsrc_codegolangsrcgithub.compkgerrors (from $GOPATH)
    F:xiaofsrc_codegolangsrcgithub.comastaxieeegoapp.go:33:2: cannot find package "golang.org/x/crypto/acme/autocert" in any of:
    D:Gosrcgolang.orgxcryptoacmeautocert (from $GOROOT)
    F:xiaofsrc_codegolangsrcgolang.orgxcryptoacmeautocert (from $GOPATH)
    F:xiaofsrc_codegolangsrcgithub.comprometheusclient_golangprometheusprocess_collector_windows.go:20:2: cannot find package "golang.org/x/sys/windows" in any of:
    D:Gosrcgolang.orgxsyswindows (from $GOROOT)
    F:xiaofsrc_codegolangsrcgolang.orgxsyswindows (from $GOPATH)

    拷贝go-admin目录下的controllers,models,routers  到F:xiaofsrc_codegolangsrcgithub.comgolangpkggo-admin

    拷贝github.commattngo-sqlite3 到$GOPATH的github.commattngo-sqlite3中

    cd $GOPATH/src/github.com/pkg ;git clone http://github.com/pkg/errors.git

    cd  $GOPATH/src/golang.org/x/ ; git clone https://github.com/golang/crypto.git

    cd $GOPATH/src/golang.org/x/; git clone https://github.com/golang/net.git;

    cd $GOPATH/src/golang.org/x/; git clone https://github.com.cnpmjs.org/golang/sys.git;

    cd $GOPATH/src/golang.org/x/; git clone https://github.com.cnpmjs.org/golang/text.git;

    报错:

    # github.com/mattn/go-sqlite3
    exec: "gcc": executable file not found in %PATH%

    https://www.cnblogs.com/zsy/p/5958170.html

    安装tdm-gcc-9.2.0  https://g.ioiox.com/https://github.com/jmeubank/tdm-gcc/releases/download/v9.2.0-tdm64-1/tdm64-gcc-9.2.0.exe

    https://jmeubank.github.io/tdm-gcc/download/

     设置环境变量path,添加D:mingw64in到path环境变量值下

    2.运行

    将代码拷贝至${GO_PATH}src/github目录下

    在vscode中运行程序,页面如下:

    3.增加调试功能

    进入命令行,在go-admin目录下运行go mod init

  • 相关阅读:
    Java应用程序的运行机制,以及JDK,JRE,JVM
    正则表达式练习题
    正则表达式
    转:DOM操作
    jQuery 遍历
    转:把一个对象赋值给另一个对象会指向同一个内存地址
    sql 语句的先后执行顺序
    数据结构时间复杂度进阶篇
    数据结构时间复杂度基础篇
    UML图中类之间的关系:依赖,泛化,关联,聚合,组合,实现(转)
  • 原文地址:https://www.cnblogs.com/beilong/p/13764942.html
Copyright © 2020-2023  润新知