Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyenought committed Feb 8, 2024
1 parent 52c9bfa commit 5aea020
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## hertz_migrate
通过分析 ast 对代码进行迁移,目前 `hertz_migrate` 支持迁移的框架有 chi (暂只支持 `func (http.ResponseWriter, *http.Request) net/http` 的迁移)

[README](./cmd/hertz_migrate/readme.md)

## 迁移脚本


Hertz-contrib 下提供了其他框架( FastHTTP、Gin ) 迁移至 Hertz 的脚本,具体使用方式如下

```shell
Expand Down Expand Up @@ -150,4 +156,4 @@ func main() {

- [Gin -> Hertz conversion table](https://github.com/hertz-contrib/migrate/blob/main/gin_to_hertz.md)

- [Hertz API Doc](https://pkg.go.dev/github.com/cloudwego/hertz)
- [Hertz API Doc](https://pkg.go.dev/github.com/cloudwego/hertz)
13 changes: 2 additions & 11 deletions cmd/hertz_migrate/internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var (

func processFiles(gofiles []string, debug bool) {
for _, path := range gofiles {
processFile(path, "", debug)
processFile(path, debug)
}
}

Expand All @@ -150,7 +150,7 @@ func beforeProcessFile(path string) {
}, nil)
}

func processFile(path, printMode string, debug bool) {
func processFile(path string, debug bool) {
var mode parser.Mode
fset := token.NewFileSet()
path, err := filepath.Abs(path)
Expand All @@ -170,15 +170,6 @@ func processFile(path, printMode string, debug bool) {

processAST(file, fset)

if debug {
if printMode == "console" {
printer.Fprint(os.Stdout, fset, file)
} else {
ast.Print(fset, file)
}
return
}

var buf bytes.Buffer
if err := printer.Fprint(&buf, fset, file); err != nil {
log.Println(err)
Expand Down
5 changes: 5 additions & 0 deletions cmd/hertz_migrate/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## hertz_migrate

### Introduction

Migrate go web code by analyzing ast, currently `hertz_migrate` supports migrating the following frameworks chi (only `func (http.ResponseWriter, *http.Request)` net/http migrations are supported for now)

### How to install

```bash
Expand Down Expand Up @@ -35,6 +39,7 @@ GLOBAL OPTIONS:
```

#### Usage

```bash
# example hertz_migration -target-dir ./haha
hertz_migrate -target-dir ${dir-name}
Expand Down

0 comments on commit 5aea020

Please sign in to comment.