git gogs source install

1.go env

1
2
3
4
5
6
[root@gitserver ~]# mkdir -p /mnt/app
[root@gitserver ~]# tar xzf go1.7.4.linux-amd64.tar.gz -C /mnt/app/
[root@gitserver ~]# echo 'export GOROOT=/mnt/app/go' |tee /etc/profile.d/go.sh
[root@gitserver ~]# echo 'export GOPATH=$HOME/work' |tee -a /etc/profile.d/go.sh
[root@gitserver ~]# echo 'export PATH=$GOROOT/bin:$PATH' |tee -a /etc/profile.d/go.sh
[root@gitserver ~]# source /etc/profile

2.gogs download

1
2
3
4
5
6
7
[root@localhost ~]# echo $GOPATH
/root/work

[root@gitserver ~]# go get -v -u github.com/gogits/gogs
[root@localhost ~]# ls ~/work/src/github.com/gogits/gogs/
appveyor.yml conf Dockerfile Dockerfile.rpi LICENSE models packager README.md routers templates
cmd docker Dockerfile.aarch64 gogs.go Makefile modules public README_ZH.md scripts vendor

3.gogs 编译安装

1
2
[root@localhost ~]# cd $GOPATH/src/github.com/gogits/gogs
[root@localhost gogs]# go build

4.gogs 启动

1
2
3
4
5
6
7
8
9
10
[root@localhost gogs]# ./gogs web
2017/03/17 17:49:39 [ WARN] Custom config '/root/work/src/github.com/gogits/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
2017/03/17 17:49:39 [TRACE] Custom path: /root/work/src/github.com/gogits/gogs/custom
2017/03/17 17:49:39 [TRACE] Log path: /root/work/src/github.com/gogits/gogs/log
2017/03/17 17:49:39 [TRACE] Log Mode: Console (Trace)
2017/03/17 17:49:39 [ INFO] Gogs 0.10.18.0313
2017/03/17 17:49:39 [ INFO] Cache Service Enabled
2017/03/17 17:49:39 [ INFO] Session Service Enabled
2017/03/17 17:49:39 [ INFO] Run Mode: Development
2017/03/17 17:49:40 [ INFO] Listen: http://0.0.0.0:3000

Go默认不支持一些功能,如果需要支持,需要使用build tag来支持

1
2
3
[root@gitserver ~]# go get -u -tags "sqlite pam cert" github.com/gogits/gogs
[root@gitserver ~]# cd $GOPATH/src/github.com/gogits/gogs
[root@localhost gogs]# go build