Golang 相关 mindoc开发

1.下载SDK

https://golang.org/dl/
下载
go1.12.windows-amd64.zip
解压放到 C:盘

2.配置环境变量

GOROOT C:\Go
GOPATH   D:\GOPATH
GOPROXY   https://goproxy.cn (go mod 需要代理)
#配置PATH添加
%GOROOT%\bin\
%GOPATH%\bin\

验证

C:\go>go version
go version go1.12 windows/amd64

C:\go>go env
C:\go>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\GOPATH
set GOPROXY=https://goproxy.cn
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxx~1\AppData\Local\Temp\go-build304895266=/tmp/go-build -gno-record-gcc-switches

C:\go>

3.WindowsGCC

下载

x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z 
https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/#readme

解压到D:\software\MinGW
配置环境变量 PATH添加

D:\software\MinGW\mingw64\bin\
C:\go>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=D:/software/MinGW/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)

C:\go>

4.github 拉取代码

#在GOPATH路径外从github克隆代码(go mod 需要)
git clone https://github.com/lifei6671/mindoc.git
#弃用dep管理软件包 改用mod
#执行
go mod init

go mod tidy
#在项目根目录生成go.mod文件

go.mod文件

module github.com/lifei6671/mindoc

go 1.12

require github.com/PuerkitoBio/goquery v1.4.1

require github.com/astaxie/beego v1.10.1

require github.com/boombuler/barcode v1.0.0

require github.com/go-sql-driver/mysql v1.4.0 // indirect

require github.com/kardianos/service v1.0.0

require github.com/lifei6671/gocaptcha v0.1.1

require github.com/mattn/go-sqlite3 v1.9.0

require github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646

require gopkg.in/ldap.v2 v2.5.1

require (
	github.com/andybalholm/cascadia v1.2.0 // indirect
	github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
	github.com/gomodule/redigo v2.0.0+incompatible // indirect
	github.com/howeyc/fsnotify v0.9.0
	github.com/lib/pq v1.9.0 // indirect
	github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
	golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
	golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7 // indirect
	google.golang.org/appengine v1.6.7 // indirect
	gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
	gopkg.in/russross/blackfriday.v2 v2.0.0
	gopkg.in/yaml.v2 v2.4.0 // indirect
)

5.dep (废弃)

https://github.com/golang/dep/releases
dep-windows-amd64.exe
重命名为dep.exe 放到%GOPATH%\bin\目录下

D:\GOPATH>dep version
dep:
 version     : v0.5.4
 build date  : 2019-07-01
 git hash    : 1f7c19e
 go version  : go1.12.6
 go compiler : gc
 platform    : windows/amd64
 features    : ImportDuringSolve=false
D:\GOPATH>

5.启动

#在项目根目录执行
go build
#生成 mindoc.exe 文件
#复制conf\app.conf.example 为app.conf 修改数据库部分
#执行初始化
mindoc.exe install
#启动
mindoc.exe
#访问
localhost:8181

6. IDE goland配置

open 项目
配置环境变量GOROOT 、GOPATH、Go models
在这里插入图片描述
在这里插入图片描述
配置RUN
在这里插入图片描述
启动
在这里插入图片描述

7. 安装 calibre

下载功能依赖calibre组件
https://calibre-ebook.com/download

8.编译

set GOOS=linux
set GOARCH=amd64
go build -o mp_doc_linux_amd64 main.go 

猜你喜欢

转载自blog.csdn.net/m0_37859032/article/details/110392430