Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33eebf6

Browse files
committed
支持 module 测试验证完毕
1 parent f2d6a94 commit 33eebf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+102
-239
lines changed

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
language: go
22

33
go:
4-
- 1.8.x
5-
- 1.9.x
4+
- 1.11.x
5+
- 1.12.x
66
- tip
77

88
sudo: false
99

10-
install:
11-
- export GOPATH=$HOME/gopath/src/github.com/studygolang/studygolang
12-
- export PATH=$PATH:$HOME/gopath/src/github.com/studygolang/studygolang/bin/
13-
- go get -v github.com/FiloSottile/gvt
14-
1510
script:
16-
- sh getpkg.sh
17-
- sh install.sh
11+
- make build

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Start from golang v1.12 base image
2+
FROM golang:1.12
3+
4+
WORKDIR /app/studygolang
5+
6+
COPY . /app/studygolang
7+
8+
RUN make build
9+
10+
CMD ["bin/studygolang"]

Dockerfile.web

Lines changed: 0 additions & 31 deletions
This file was deleted.

Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
22

33
v=""
44

5+
export GOPROXY=https://goproxy.cn
6+
export GO111MODULE=on
7+
58
BUILD = $(shell git symbolic-ref HEAD | cut -b 12-)-$(shell git rev-parse HEAD)
69

710
build:
811
if [ ! -d log ]; then mkdir log; fi
912

13+
gofmt -w -s .
14+
1015
go build -ldflags "-X global.Build=$(BUILD)" -o bin/studygolang github.com/studygolang/studygolang/cmd/studygolang
1116

17+
@echo "build successfully!"
18+
1219
reload:
13-
./reload.sh
20+
kill -USR2 `cat pid/*.pid`
21+
22+
echo 'reload successfully'
1423

1524
start:
16-
./start.sh
25+
if [ ! -d pid ]; then mkdir pid; fi
26+
export GOTRACEBACK=crash
27+
ulimit -c unlimited
28+
29+
bin/studygolang >> log/panic.log 2>&1 &
30+
31+
@echo "start successfully"
1732

1833
stop:
19-
./stop.sh
34+
kill `cat pid/*.pid`
35+
sleep 1
36+
rm -rf pid/*.pid

cmd/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
)
2121

2222
var (
23-
manualIndex = flag.Bool("manual", false, "do manual index once or not")
24-
needAll = flag.Bool("all", false, "是否需要全量抓取,默认否")
25-
whichSite = flag.String("site", "", "抓取哪个站点(空表示所有站点)")
23+
manualIndex = flag.Bool("manual", false, "do manual index once or not")
24+
needAll = flag.Bool("all", false, "是否需要全量抓取,默认否")
25+
whichSite = flag.String("site", "", "抓取哪个站点(空表示所有站点)")
2626
)
2727

2828
func IndexingServer() {

db/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
. "github.com/polaris1119/config"
1515

1616
_ "github.com/go-sql-driver/mysql"
17-
"xorm.io/core"
1817
"github.com/go-xorm/xorm"
18+
"xorm.io/core"
1919
)
2020

2121
var MasterDB *xorm.Engine

docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: '3'
2+
services:
3+
studygolang:
4+
container_name: studygolang
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
ports:
9+
- 8088:8088
10+
networks:
11+
- default
12+
- app_net
13+
external_links:
14+
- redis:redis
15+
- mysql:mysql
16+
volumes:
17+
- ./static:/app/studygolang/static
18+
- ./template:/app/studygolang/template
19+
- ./log:/app/studygolang/log
20+
21+
networks:
22+
app_net:
23+
external: true

docker-entrypoint.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

http/controller/account.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ import (
1212
"net/url"
1313
"strings"
1414
"time"
15-
1615

17-
. "github.com/studygolang/studygolang/http/internal/helper"
16+
"github.com/studygolang/studygolang/context"
1817
. "github.com/studygolang/studygolang/http"
18+
. "github.com/studygolang/studygolang/http/internal/helper"
1919
"github.com/studygolang/studygolang/http/middleware"
2020
"github.com/studygolang/studygolang/logic"
2121
"github.com/studygolang/studygolang/model"
2222
"github.com/studygolang/studygolang/util"
23-
"github.com/studygolang/studygolang/context"
2423

2524
"github.com/dchest/captcha"
2625
"github.com/gorilla/sessions"

http/controller/admin/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package admin
99
import echo "github.com/labstack/echo/v4"
1010

1111
func RegisterRoutes(g *echo.Group) {
12+
g.GET("", AdminIndex)
1213
new(AuthorityController).RegisterRoute(g)
1314
new(UserController).RegisterRoute(g)
1415
new(TopicController).RegisterRoute(g)

http/controller/app/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
package app
88

99
import (
10-
"github.com/studygolang/studygolang/logic"
11-
"github.com/studygolang/studygolang/model"
1210
"github.com/studygolang/studygolang/context"
1311
. "github.com/studygolang/studygolang/http"
1412
. "github.com/studygolang/studygolang/http/internal/helper"
13+
"github.com/studygolang/studygolang/logic"
14+
"github.com/studygolang/studygolang/model"
1515

1616
echo "github.com/labstack/echo/v4"
1717
)

install.bat

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@ goto end
88

99
:ok
1010

11-
set GOBIN=
12-
set OLDGOPATH=%GOPATH%
13-
set GOPATH=%~dp0
11+
set GOPROXY=https://goproxy.cn
12+
set GO111MODULE=on
1413

1514
if not exist log mkdir log
1615

17-
gofmt -w -s src
16+
gofmt -w -s .
1817

19-
go install server/studygolang
20-
go install server/indexer
21-
go install server/crawler
22-
go install server/migrator
23-
24-
set GOPATH=%OLDGOPATH%
18+
go build -o bin/studygolang.exe github.com/studygolang/studygolang/cmd/studygolang
2519

2620
:end
2721
echo finished

install.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

logic/ad.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
package logic
88

99
import (
10-
"github.com/studygolang/studygolang/model"
1110
. "github.com/studygolang/studygolang/db"
11+
"github.com/studygolang/studygolang/model"
1212

1313
"github.com/polaris1119/set"
1414
"golang.org/x/net/context"

logic/article.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
package logic
88

99
import (
10+
"context"
1011
"errors"
1112
"fmt"
1213
"net/url"
1314
"regexp"
1415
"strconv"
1516
"strings"
16-
"context"
1717
"time"
1818

1919
"github.com/PuerkitoBio/goquery"
@@ -28,9 +28,9 @@ import (
2828
"github.com/tidwall/gjson"
2929
"golang.org/x/text/encoding/simplifiedchinese"
3030

31+
. "github.com/studygolang/studygolang/db"
3132
"github.com/studygolang/studygolang/global"
3233
"github.com/studygolang/studygolang/model"
33-
. "github.com/studygolang/studygolang/db"
3434
)
3535

3636
type ArticleLogic struct{}

logic/authority.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"net/url"
1111
"strconv"
1212

13+
. "github.com/studygolang/studygolang/db"
1314
"github.com/studygolang/studygolang/global"
1415
"github.com/studygolang/studygolang/model"
15-
. "github.com/studygolang/studygolang/db"
1616

1717
"github.com/polaris1119/logger"
1818
"golang.org/x/net/context"

logic/comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"strings"
1616
"time"
1717

18-
"github.com/studygolang/studygolang/model"
1918
. "github.com/studygolang/studygolang/db"
19+
"github.com/studygolang/studygolang/model"
2020

2121
"github.com/fatih/structs"
2222
"github.com/polaris1119/goutils"

logic/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"errors"
1111
"fmt"
1212
"github.com/studygolang/studygolang/model"
13+
"github.com/studygolang/studygolang/util"
1314
"os"
1415
"regexp"
1516
"strconv"
1617
"time"
17-
"github.com/studygolang/studygolang/util"
1818

1919
"github.com/gorilla/schema"
2020
"github.com/polaris1119/goutils"

logic/download.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"net/http"
1111
"strings"
1212

13-
"github.com/studygolang/studygolang/model"
1413
. "github.com/studygolang/studygolang/db"
14+
"github.com/studygolang/studygolang/model"
1515

16-
"golang.org/x/net/context"
1716
"github.com/PuerkitoBio/goquery"
1817
"github.com/polaris1119/goutils"
1918
"github.com/polaris1119/logger"
19+
"golang.org/x/net/context"
2020
)
2121

2222
type DownloadLogic struct{}

logic/email.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"strings"
1616
"time"
1717

18-
"github.com/studygolang/studygolang/global"
1918
. "github.com/studygolang/studygolang/db"
19+
"github.com/studygolang/studygolang/global"
2020
"github.com/studygolang/studygolang/model"
2121
"github.com/studygolang/studygolang/util"
2222

0 commit comments

Comments
 (0)