Skip to content

Commit f0fa04e

Browse files
committed
feat: 更新例子
1 parent 4d86dcc commit f0fa04e

95 files changed

Lines changed: 1605 additions & 3230 deletions

Some content is hidden

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

.env

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
11
# 注释
2-
app.env=local
3-
app.name=goal
4-
app.debug=true
5-
app.timezone=Asia/Shanghai
2+
name=goal
63

7-
app.key=123456781234567812345678
4+
app.key=dQcxsKvBZKNfWivwnhKlDwvseguknBZPEiiDRQlIatjKLLpbzK
5+
app.env=local
86

97
http.host=0.0.0.0
108
http.port=8008
119

12-
db.connection=sqlite
10+
sqlite.database=/Users/qbhy/project/go/goal-web/goal/example/database/db.sqlite
1311

14-
db.sqlite.database=/Users/qbhy/project/go/goal-web/example/database/db.sqlite
12+
queue.connection=nsq
13+
queue.kafka.brokers=localhost:9092
14+
queue.nsq.address=localhost:49162
1515

16-
db.host=hsy
17-
db.port=3306
16+
db.connection=sqlite
17+
db.host=localhost
18+
db.port=3308
1819
db.database=goal
1920
db.username=root
20-
db.password=%TGB6yhn
21+
db.password=123456
2122

22-
db.pgsql.host=hsy
23+
db.pgsql.host=localhost
2324
db.pgsql.port=55433
2425
db.pgsql.database=postgres
2526
db.pgsql.username=postgres
2627
db.pgsql.password=123456
2728

28-
db.clickhouse.address=hsy:9000
29-
db.clickhouse.database=default
30-
db.clickhouse.username=default
31-
db.clickhouse.password=
32-
db.clickhouse.debug=true
33-
34-
# redis.host=localhost
35-
redis.host=localhost
29+
redis.host=hsy
3630
redis.port=6379
37-
redis.db=2
3831
#redis.password=123456
3932

4033
redis.cache.host=hsy
@@ -57,21 +50,16 @@ hashing.hashers.md5.salt=goal
5750
# 文件系统配置
5851
filesystem.driver=local
5952
filesystem.root=/Users/qbhy/project/go/goal/
60-
filesystem.name=root
6153
filesystem.perm=0777
6254

63-
# session 配置
64-
session.id=goal
65-
session.name=goal_session
66-
session.lifetime=36000
67-
68-
auth.jwt.secret=jwt_secret
69-
auth.default=jwt
55+
qiniu.private=false
56+
qiniu.bucket=aa
57+
qiniu.domain=https://xxx.xxx.com
58+
qiniu.access_key=
59+
qiniu.secret_key=
7060

7161

72-
queue.connection=nsq
73-
queue.kafka.brokers=localhost:9092
74-
queue.nsq.address=localhost:62336
75-
62+
# session 配置
63+
session.id=goal
64+
session.name=goal_session:
7665

77-
micro.etcd.address=localhost:2379

.github/workflows/go.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: goal
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v3
21+
with:
22+
go-version: 1.19
23+
24+
- name: Build
25+
run: go build -v ./...
26+
27+
- name: Test
28+
run: go test -v ./...

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
.idea
12
database/*.sqlite
2-
public/*
3-
goal.pid
3+
*.pid
44
storage/*
55

66
/real.env
77

8-
/bin_*
8+
/bin*

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
FROM alpine
22

3-
RUN mkdir "/opt/app"
4-
53
COPY ./bin_linux /opt/app/app
64

75
ENV http.port 8008
86

97
EXPOSE 8008
108

11-
WORKDIR /opt/app
9+
WORKDIR /app
1210

13-
ENTRYPOINT /opt/app/app run
11+
ENTRYPOINT /app/goal run

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 桥边红药
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,13 @@
1-
# Go parameters
2-
GOCMD=go
3-
GOBUILD=$(GOCMD) build
4-
GOCLEAN=$(GOCMD) clean
5-
GOTEST=go test
6-
GOGET=$(GOCMD) get
71
DOCKER_TAG=goal
82

93
run:
10-
$(GOCMD) run main.go run
11-
12-
migrate:
13-
$(GOCMD) run main.go migrate
14-
15-
migrate-rollback:
16-
$(GOCMD) run main.go migrate:rollback
17-
18-
migrate-refresh:
19-
$(GOCMD) run main.go migrate:refresh
20-
21-
migrate-reset:
22-
$(GOCMD) run main.go migrate:reset
23-
24-
migrate-status:
25-
$(GOCMD) run main.go migrate:status
26-
27-
build-linux:
28-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o ./bin_linux -v ./
29-
30-
build-windows:
31-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o ./bin_windows.exe -v ./
32-
33-
build-mac:
34-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o ./bin_mac -v ./
35-
36-
win-build-linux:
37-
SET CGO_ENABLED=0 SET GOOS=linux SET GOARCH=amd64 $(GOBUILD) -o ./bin_linux -v ./
38-
39-
win-build-mac:
40-
SET CGO_ENABLED=0 SET GOOS=darwin SET GOARCH=amd64 $(GOBUILD) -o ./bin_mac -v ./
41-
42-
win-build:
43-
$(GOBUILD) -o ./bin_goal.exe -v ./
4+
go run bootstrap/app/main.go run
445

456
build:
46-
$(GOBUILD) -o ./bin_goal -v ./
7+
go build -o ./bin_goal -v ./
478

489
test:
49-
$(GOTEST) -json ./tests
10+
go test -json ./tests
5011

51-
pack: build-linux
12+
pack:
5213
docker build -t $(DOCKER_TAG) .
53-
54-
test-and-pack: test pack

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Goal Framework
2+
[![codecov](https://codecov.io/gh/goal-web/goal/branch/master/graph/badge.svg)](https://codecov.io/gh/goal-web/goal)
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/goal-web/goal)](https://goreportcard.com/report/github.com/goal-web/goal)
4+
[![GoDoc](https://pkg.go.dev/badge/github.com/goal-web/goal?status.svg)](https://pkg.go.dev/github.com/goal-web/goal?tab=doc)
5+
[![Join the chat at https://gitter.im/goal-web/goal](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/goal-web/goal?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6+
[![Sourcegraph](https://sourcegraph.com/github.com/goal-web/goal/-/badge.svg)](https://sourcegraph.com/github.com/goal-web/contracts?badge)
7+
[![Open Source Helpers](https://www.codetriage.com/goal-web/goal/badges/users.svg)](https://www.codetriage.com/goal-web/goal)
8+
[![Release](https://img.shields.io/github/release/goal-web/goal.svg?style=flat-square)](https://github.com/goal-web/goal/releases)
9+
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/goal-web/goal)](https://www.tickgit.com/browse?repo=github.com/goal-web/goal)
10+
11+
## About Goal Framework
12+
13+
Goal Framework is a common application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Goal Framework takes the pain out of development by easing common tasks used in many web projects, such as:
14+
15+
- [Simple and powerful middleware](https://github.com/goal-web/pipeline).
16+
- [Powerful dependency injection container](https://github.com/goal-web/container).
17+
- Multiple back-ends for [session](https://github.com/goal-web/session) and [cache](https://github.com/goal-web/cache) storage.
18+
- Expressive, intuitive [database](https://github.com/goal-web/database).
19+
- [Robust background job processing](https://github.com/goal-web/queue).
20+
21+
Goal framework is accessible, powerful, and provides tools required for large, robust applications.
22+
23+
## Learning Goal Framework
24+
* [Installation](https://github.com/goal-web/doc/blob/wiki/%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97/%E5%AE%89%E8%A3%85.md)
25+
* [Documents](https://github.com/goal-web/doc/blob/wiki/README.md)
26+
27+
## Contributing
28+
29+
Thank you for considering contributing to the Goal framework! The contribution guide can be found in the [Goal documentation](https://github.com/goal-web/doc/blob/wiki/%E5%89%8D%E8%A8%80/%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%BC%95.md).
30+
31+
## License
32+
33+
The Goal framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package app
2+

app/console/commands/hello.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Hello struct {
1616
commands.Command
1717
}
1818

19-
func (this Hello) Handle() interface{} {
20-
logs.Default().Info("hello goal " + this.GetString("say"))
19+
func (hello Hello) Handle() any {
20+
logs.Default().Info("hello goal " + hello.GetString("say"))
2121
return nil
2222
}

app/console/commands/runner.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package commands
2+
3+
import (
4+
"fmt"
5+
"github.com/goal-web/contracts"
6+
"github.com/goal-web/supports/commands"
7+
"github.com/goal-web/supports/logs"
8+
"os"
9+
)
10+
11+
type runner struct {
12+
commands.Command
13+
app contracts.Application
14+
}
15+
16+
func Runner(app contracts.Application) contracts.Command {
17+
return &runner{
18+
Command: commands.Base("run", "启动 goal"),
19+
app: app,
20+
}
21+
}
22+
23+
func (runner *runner) Handle() any {
24+
path, _ := os.Getwd()
25+
pidPath := path + "/goal.pid"
26+
// 写入 pid 文件
27+
_ = os.WriteFile(pidPath, []byte(fmt.Sprintf("%d", os.Getpid())), os.ModePerm)
28+
29+
if errors := runner.app.Start(); len(errors) > 0 {
30+
logs.WithField("errors", errors).Fatal("goal 启动异常!")
31+
} else {
32+
_ = os.Remove(pidPath)
33+
logs.Default().Info("goal 已关闭")
34+
}
35+
return nil
36+
}

0 commit comments

Comments
 (0)