Skip to content

Commit 7225631

Browse files
committed
0
1 parent 75356bc commit 7225631

File tree

40 files changed

+699
-2
lines changed

40 files changed

+699
-2
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ db.Exec(`CREATE TABLE users (
2626
fmt.Println(rows)
2727
~~~
2828

29-
goframe中只需在boot 下面go文件里面加上 `_ github.com/logoove/sqlite`即可在orm使用,不需要任何其他修改
29+
goframe1.16中只需在boot 下面go文件里面加上 `_ github.com/logoove/sqlite`即可在orm使用,不需要任何其他修改
30+
goframe2.0中,在manifeat/config/config.yaml配置
31+
~~~
32+
# 数据库连接配置
33+
database:
34+
logger:
35+
path: "./temp/logs/sql"
36+
level: "all"
37+
stdout: true
38+
ctxKeys: ["RequestId"]
39+
default:
40+
type: "sqlite"
41+
link: "./resource/db.db" #数据库路径根据自己的填写
42+
debug: true
43+
~~~
44+
,在internel/cmd/cmd.go 中加入_ "github.com/logoove/sqlite"即可,已经将驱动改成sqlite3,所以能够直接在goframe中使用.
45+
插入数据
46+
~~~
47+
id, _ := g.Model("user").Data(g.Map{"name": "john", "age": 1}).InsertAndGetId()
48+
~~~
3049
### 更新日志
50+
2022-3-22 v1.15.3 新增win amd64编译,解决内存泄漏问题.
3151
2021-11-3 v1.13.0 新增更多系统编译,支持sqlite 3.36.0

examples/gflay/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.buildpath
2+
.hgignore.swp
3+
.project
4+
.orig
5+
.swp
6+
.idea/
7+
.settings/
8+
.vscode/
9+
vendor/
10+
composer.lock
11+
gitpush.sh
12+
pkg/
13+
bin/
14+
cbuild
15+
**/.DS_Store
16+
.vscode/
17+
.test/
18+
main
19+
output/
20+
manifest/output/

examples/gflay/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) 2022 yoby
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.

examples/gflay/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# goframe2.0例子
2+
编译
3+
go build
4+
访问
5+
http://127.0.0.1:8000/hello

examples/gflay/api/v1/hello.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package v1
2+
3+
import (
4+
"github.com/gogf/gf/v2/frame/g"
5+
)
6+
7+
type HelloReq struct {
8+
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
9+
}
10+
type HelloRes struct {
11+
g.Meta `mime:"text/html" example:"string"`
12+
}

examples/gflay/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module gflay
2+
3+
go 1.15
4+
5+
require (
6+
github.com/gogf/gf/v2 v2.0.0-rc.0.20220117131058-9345eb5e946f
7+
github.com/logoove/sqlite v1.13.0
8+
github.com/russross/blackfriday/v2 v2.1.0
9+
modernc.org/sqlite v1.15.3 // indirect
10+
)

examples/gflay/go.sum

Lines changed: 310 additions & 0 deletions
Large diffs are not rendered by default.

examples/gflay/internal/cmd/cmd.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
6+
"gflay/internal/controller"
7+
"github.com/gogf/gf/v2/frame/g"
8+
"github.com/gogf/gf/v2/net/ghttp"
9+
"github.com/gogf/gf/v2/os/gcmd"
10+
_ "github.com/logoove/sqlite"
11+
)
12+
13+
var (
14+
Main = gcmd.Command{
15+
Name: "main",
16+
Usage: "main",
17+
Brief: "start http server",
18+
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
19+
s := g.Server()
20+
s.Group("/", func(group *ghttp.RouterGroup) {
21+
group.Middleware(ghttp.MiddlewareHandlerResponse)
22+
group.Bind(
23+
controller.Hello,
24+
)
25+
})
26+
s.Run()
27+
return nil
28+
},
29+
}
30+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package consts
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package controller
2+
3+
import (
4+
"context"
5+
"gflay/api/v1"
6+
7+
"github.com/gogf/gf/v2/frame/g"
8+
)
9+
10+
var (
11+
Hello = cHello{}
12+
)
13+
14+
type cHello struct{}
15+
16+
func (h *cHello) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
17+
id, _ := g.Model("user").Data(g.Map{"name": "john", "age": 1}).InsertAndGetId()
18+
g.RequestFromCtx(ctx).Response.Writeln("Hello World!", id)
19+
return
20+
}

0 commit comments

Comments
 (0)