Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Nov 25, 2024
1 parent af682a2 commit d4fec36
Show file tree
Hide file tree
Showing 141 changed files with 523 additions and 392 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module replace
module replace_md_link

go 1.23.1

Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions .scripts/replace_md_link/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"

"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
)

const (
path = `/Users/john/Workspace/github/gogf/gf-site/i18n/en/docusaurus-plugin-content-docs`
)

func main() {
files, err := gfile.ScanDirFile(path, "*.md", true)
if err != nil {
panic(err)
}
for _, file := range files {
content := gfile.GetContents(file)
newContent, _ := gregex.ReplaceStringFuncMatch(
`\[([^\]]+?)\]\(([^\)]+?\.md)\)`,
content,
func(match []string) string {
var (
name = match[1]
link = match[2]
)
if gstr.HasPrefix(link, "http") {
return match[0]
}
if gstr.Contains(link, " ") {
link = gstr.Replace(link, " ", "%20")
}
return fmt.Sprintf(`[%s](%s)`, name, link)
},
)
_ = gfile.PutContents(file, newContent)
}
}
29 changes: 29 additions & 0 deletions .scripts/replace_md_name/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module replace_md_name

go 1.23.1

require github.com/gogf/gf/v2 v2.7.4

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
58 changes: 58 additions & 0 deletions .scripts/replace_md_name/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/gogf/gf/v2 v2.7.4 h1:cGHUBO5Jr8ty21GN5EO+S2rFYhprdcqnwS7PnWL7+t4=
github.com/gogf/gf/v2 v2.7.4/go.mod h1:EBXneAg/wes86rfeh68XC0a2JBNQylmT7Sp6/8Axk88=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ func main() {
}
// get title from md
fileContent := gstr.Trim(gfile.GetContents(realPath))
tempMatch, _ := gregex.MatchString(`title: '(\w+?)'`, fileContent)
tempMatch, _ := gregex.MatchString(`title: '(.+?)'`, fileContent)
if len(tempMatch) > 1 {
name = tempMatch[1]
}
if gstr.Contains(link, " ") {
link = gstr.Replace(link, " ", "%20")
}
return fmt.Sprintf(`[%s](%s)`, name, link)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This session will mainly share some design concepts of the framework, without di
3. [Framework Design](../../../docs/框架设计/框架设计.md)
- [Modular Design](../../../docs/框架设计/模块化设计.md)
- [Unified Framework Design](../../../docs/框架设计/统一框架设计.md)
- [Code Layer Design](../../../docs/框架设计/工程开发设计/代码分层设计.md)
- [Code Layering](../../../docs/框架设计/工程开发设计/代码分层设计.md)
4. Other Miscellaneous Items
5. Community-Driven Development Plans
6. Interaction Session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ build running pid: 8648
----------|--------|--------------------|---------------------------------------------------------|----------------------------------
```

The result of running prints out three interface addresses. `/swagger` and `/api.json` are interface document addresses generated by the framework, which we will explain in detail in [2.5 - Interface Documentation](./2.5.接口文档.md). The other address `/v1/users/register` is the user registration interface we developed. Send a `POST` request to test it.
The result of running prints out three interface addresses. `/swagger` and `/api.json` are interface document addresses generated by the framework, which we will explain in detail in [2.5 API Documentation](./2.5.接口文档.md). The other address `/v1/users/register` is the user registration interface we developed. Send a `POST` request to test it.

```bash
$ curl -X POST http://127.0.0.1:8000/v1/users/register -H "Content-Type: application/json" -d "{\"username\":\"oldme\", \"password\":\"123456\", \"email\":\"tyyn1022@gmail.com\"}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The file storage method works well in single-node scenarios, but when it comes t

The `gsession` Redis storage uses the `StorageRedis` object, similar to file storage. To improve execution efficiency, it adopts a `memory + Redis` approach. The only difference from file storage is that if `Session` operations are needed during each request, the latest `Session` data will be pulled from `Redis` (file storage only reads a file once when the `Session` does not exist). At the end of each request, the entire `Session` data is serialized using `JSON` and updated to the `Redis` service using the `KeyValue` method.
:::tip
For business scenarios where the `Session` data of each user is not large (taking the user dimension as an example), this storage method is recommended. If the `Session` data for a single user is large (e.g., `>10MB`), you can refer to the `HashTable` storage method: [Session-Redis-HashTable](Session-Redis-HashTable.md)
For business scenarios where the `Session` data of each user is not large (taking the user dimension as an example), this storage method is recommended. If the `Session` data for a single user is large (e.g., `>10MB`), you can refer to the `HashTable` storage method: [Session - Redis-HashTable](Session-Redis-HashTable.md)
:::
## Usage Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ The timing of each method's invocation is explained in detail within the comment
## Considerations

- In the `Storage` interface, not all interface methods need to be implemented. Developers only need to implement some interfaces according to the specific invocation timing required by their business needs.
- To enhance the execution performance of `Session`, the interface uses the `gmap.StrAnyMap` container type. During development, you can refer to this section: [Dictionary Type - gmap](../../组件列表/数据结构/字典类型-gmap/字典类型-gmap.md)
- To enhance the execution performance of `Session`, the interface uses the `gmap.StrAnyMap` container type. During development, you can refer to this section: [Map](../../组件列表/数据结构/字典类型-gmap/字典类型-gmap.md)
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ The management functionality of `Session` is implemented by the independent `gse

| Storage | Distributed Support | Persistence Support | Memory Usage | Execution Efficiency | Brief Introduction |
| --- | --- | --- | --- | --- | --- |
| `StorageFile` | No | Yes | Medium | Medium | Based on file storage (default). A more efficient persistent storage method under single-node deployment: [Session-File](Session-File.md) |
| `StorageMemory` | No | No | High | High | Based on pure memory storage. Single-node deployment, highest performance, but cannot be persisted, and is lost on restart: [Session-Memory](Session-Memory.md) |
| `StorageRedis` | Yes | Yes | Medium | Medium | Based on `Redis` storage (`Key-Value`). Remote `Redis` node stores `Session` data, supporting multi-node deployment: [Session-Redis-KeyValue](Session-Redis-KeyValue.md) |
| `StorageRedisHashTable` | Yes | Yes | Low | Low | Based on `Redis` storage (`HashTable`). Remote `Redis` node stores `Session` data, supporting multi-node deployment: [Session-Redis-HashTable](Session-Redis-HashTable.md) |
| `StorageFile` | No | Yes | Medium | Medium | Based on file storage (default). A more efficient persistent storage method under single-node deployment: [Session - File](Session-File.md) |
| `StorageMemory` | No | No | High | High | Based on pure memory storage. Single-node deployment, highest performance, but cannot be persisted, and is lost on restart: [Session - Memory](Session-Memory.md) |
| `StorageRedis` | Yes | Yes | Medium | Medium | Based on `Redis` storage (`Key-Value`). Remote `Redis` node stores `Session` data, supporting multi-node deployment: [Session - Redis-KeyValue](Session-Redis-KeyValue.md) |
| `StorageRedisHashTable` | Yes | Yes | Low | Low | Based on `Redis` storage (`HashTable`). Remote `Redis` node stores `Session` data, supporting multi-node deployment: [Session - Redis-HashTable](Session-Redis-HashTable.md) |

Each method has its advantages and disadvantages. For detailed introductions, please refer to the corresponding sections.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function DoAjax(url) {

Please refer to subsequent chapters for specific usage examples.

## Related Documents
## Documents

import DocCardList from '@theme/DocCardList';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ func main() {
}
```

This is an example of a mixed routing rule, used to display a specific class, subject, student, and corresponding action. After running, we can see the test result by visiting this address: [http://127.0.0.1:8199/class3-math/john/score](http://127.0.0.1:8199/class3-math/john/score). On the page, you can see that the routing rules are parsed one by one, and the business layer can process the corresponding business logic according to the parsed parameters. For specific route registration management, please see the subsequent [Routing Management - Routing Rules](路由管理/路由管理-路由规则.md) chapter.
This is an example of a mixed routing rule, used to display a specific class, subject, student, and corresponding action. After running, we can see the test result by visiting this address: [http://127.0.0.1:8199/class3-math/john/score](http://127.0.0.1:8199/class3-math/john/score). On the page, you can see that the routing rules are parsed one by one, and the business layer can process the corresponding business logic according to the parsed parameters. For specific route registration management, please see the subsequent [Router - Route Patterns](路由管理/路由管理-路由规则.md) chapter.

## Configuration Management

The core components of `GoFrame` implement convenient configuration management features, allowing component functionality configuration through configuration file modifications. In most scenarios, we recommend using configuration files to manage component configurations. For `Server` configurations, see the [Service Configuration](服务配置/服务配置.md) chapter.
The core components of `GoFrame` implement convenient configuration management features, allowing component functionality configuration through configuration file modifications. In most scenarios, we recommend using configuration files to manage component configurations. For `Server` configurations, see the [Configuration](服务配置/服务配置.md) chapter.

## Graceful Restart

`Server` has built-in support for graceful restart features. Detailed introduction can be found in the [Graceful Restart Features](高级特性/平滑重启特性.md) chapter.
`Server` has built-in support for graceful restart features. Detailed introduction can be found in the [Graceful Restart](高级特性/平滑重启特性.md) chapter.

## HTTPS Support

`Server` supports `HTTPS` services and also supports providing `HTTP&HTTPS` services in a single process. Detailed `HTTPS` introduction can be found in the [HTTPS&TLS](高级特性/HTTPS%20&%20TLS.md) chapter.
`Server` supports `HTTPS` services and also supports providing `HTTP&HTTPS` services in a single process. Detailed `HTTPS` introduction can be found in the [HTTPS & TLS](高级特性/HTTPS%20&%20TLS.md) chapter.

## More Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Here, we use a global post-middleware to capture exceptions. When an exception o
Please note:

- Even if developers capture and log exceptions themselves, the `Server` will still print them to its own error log file. Logs outputted by API methods are business logs (related to the business), while self-managed logs by the `Server` are service logs (similar to `nginx`'s `error.log`).
- Since most low-level errors in the `goframe` framework include stack information of the error, if you are interested in specific stack information (call chain, error file path, source code line number, etc.), you can use `gerror` to retrieve it. For details, please refer to the section [Error Handling - Stack Features](../核心组件/错误处理/错误处理-堆栈特性.md). If the exception includes stack information, it is printed by default to the `Server`'s `error` log file.
- Since most low-level errors in the `goframe` framework include stack information of the error, if you are interested in specific stack information (call chain, error file path, source code line number, etc.), you can use `gerror` to retrieve it. For details, please refer to the section [Error Handling - Stack](../核心组件/错误处理/错误处理-堆栈特性.md). If the exception includes stack information, it is printed by default to the `Server`'s `error` log file.
:::
```go
package main
Expand Down Expand Up @@ -127,7 +127,7 @@ func main() {
}
```

You can see that we use the `%+v` formatted print to retrieve the stack information from the exception error; for the specific principle, please refer to the chapter: [Error Handling - Stack Features](../核心组件/错误处理/错误处理-堆栈特性.md). After execution, we will test it with the `curl` tool:
You can see that we use the `%+v` formatted print to retrieve the stack information from the exception error; for the specific principle, please refer to the chapter: [Error Handling - Stack](../核心组件/错误处理/错误处理-堆栈特性.md). After execution, we will test it with the `curl` tool:

```bash
$ curl "http://127.0.0.1:8199/api.v2/user/list"
Expand Down
Loading

0 comments on commit d4fec36

Please sign in to comment.