chore(format): change by gofumpt tool (#697)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2021-05-18 14:43:09 +08:00
committed by GitHub
parent 73417f54db
commit 73906f996d
21 changed files with 47 additions and 47 deletions

View File

@@ -33,7 +33,7 @@ const (
`
)
func genDoc(api *spec.ApiSpec, dir string, filename string) error {
func genDoc(api *spec.ApiSpec, dir, filename string) error {
fp, _, err := util.MaybeCreateFile(dir, "", filename)
if err != nil {
return err

View File

@@ -42,7 +42,7 @@ func (v *ApiVisitor) VisitApi(ctx *api.ApiContext) interface{} {
return &final
}
func (v *ApiVisitor) acceptService(root *Api, final *Api) {
func (v *ApiVisitor) acceptService(root, final *Api) {
for _, service := range root.Service {
if _, ok := final.serviceM[service.ServiceApi.Name.Text()]; !ok && len(final.serviceM) > 0 {
v.panic(service.ServiceApi.Name, fmt.Sprintf("mutiple service declaration"))
@@ -104,7 +104,7 @@ func (v *ApiVisitor) duplicateServerItemCheck(service *Service) {
}
}
func (v *ApiVisitor) acceptType(root *Api, final *Api) {
func (v *ApiVisitor) acceptType(root, final *Api) {
for _, tp := range root.Type {
if _, ok := final.typeM[tp.NameExpr().Text()]; ok {
v.panic(tp.NameExpr(), fmt.Sprintf("duplicate type '%s'", tp.NameExpr().Text()))
@@ -115,7 +115,7 @@ func (v *ApiVisitor) acceptType(root *Api, final *Api) {
}
}
func (v *ApiVisitor) acceptInfo(root *Api, final *Api) {
func (v *ApiVisitor) acceptInfo(root, final *Api) {
if root.Info != nil {
infoM := map[string]PlaceHolder{}
if final.Info != nil {
@@ -133,7 +133,7 @@ func (v *ApiVisitor) acceptInfo(root *Api, final *Api) {
}
}
func (v *ApiVisitor) acceptImport(root *Api, final *Api) {
func (v *ApiVisitor) acceptImport(root, final *Api) {
for _, imp := range root.Import {
if _, ok := final.importM[imp.Value.Text()]; ok {
v.panic(imp.Import, fmt.Sprintf("duplicate import '%s'", imp.Value.Text()))
@@ -144,7 +144,7 @@ func (v *ApiVisitor) acceptImport(root *Api, final *Api) {
}
}
func (v *ApiVisitor) acceptSyntax(root *Api, final *Api) {
func (v *ApiVisitor) acceptSyntax(root, final *Api) {
if root.Syntax != nil {
if final.Syntax != nil {
v.panic(root.Syntax.Syntax, fmt.Sprintf("mutiple syntax declaration"))

View File

@@ -177,7 +177,7 @@ func (p *Parser) invoke(linePrefix, content string) (v *Api, err error) {
return
}
func (p *Parser) valid(mainApi *Api, nestedApi *Api) error {
func (p *Parser) valid(mainApi, nestedApi *Api) error {
err := p.nestedApiCheck(mainApi, nestedApi)
if err != nil {
return err
@@ -237,7 +237,7 @@ func (p *Parser) valid(mainApi *Api, nestedApi *Api) error {
return nil
}
func (p *Parser) duplicateRouteCheck(nestedApi *Api, mainHandlerMap map[string]PlaceHolder, mainRouteMap map[string]PlaceHolder) error {
func (p *Parser) duplicateRouteCheck(nestedApi *Api, mainHandlerMap, mainRouteMap map[string]PlaceHolder) error {
for _, each := range nestedApi.Service {
for _, r := range each.ServiceApi.ServiceRoute {
handler := r.GetHandler()
@@ -260,7 +260,7 @@ func (p *Parser) duplicateRouteCheck(nestedApi *Api, mainHandlerMap map[string]P
return nil
}
func (p *Parser) nestedApiCheck(mainApi *Api, nestedApi *Api) error {
func (p *Parser) nestedApiCheck(mainApi, nestedApi *Api) error {
if len(nestedApi.Import) > 0 {
importToken := nestedApi.Import[0].Import
return fmt.Errorf("%s line %d:%d the nested api does not support import",

View File

@@ -136,7 +136,7 @@ func TestGenCacheKeys(t *testing.T) {
})
}
func cacheKeyEqual(k1 Key, k2 Key) bool {
func cacheKeyEqual(k1, k2 Key) bool {
k1Join := k1.FieldNameJoin
k2Join := k2.FieldNameJoin
sort.Strings(k1Join)

View File

@@ -28,7 +28,7 @@ type (
StudentModel interface {
Insert(data Student) (sql.Result, error)
FindOne(id int64) (*Student, error)
FindOneByClassName(class string, name string) (*Student, error)
FindOneByClassName(class, name string) (*Student, error)
Update(data Student) error
// only for test
Delete(id int64, className, studentName string) error
@@ -85,7 +85,7 @@ func (m *defaultStudentModel) FindOne(id int64) (*Student, error) {
}
}
func (m *defaultStudentModel) FindOneByClassName(class string, name string) (*Student, error) {
func (m *defaultStudentModel) FindOneByClassName(class, name string) (*Student, error) {
studentClassNameKey := fmt.Sprintf("%s%v%v", cacheStudentClassNamePrefix, class, name)
var resp Student
err := m.QueryRowIndex(&resp, studentClassNameKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {

View File

@@ -136,7 +136,7 @@ func getCommand(arg string) (string, bool, error) {
return arg, false, nil
}
func downloadFile(filepath string, url string) error {
func downloadFile(filepath, url string) error {
resp, err := http.Get(url)
if err != nil {
return err

View File

@@ -15,7 +15,7 @@ import (
// Run provides the execution of shell scripts in golang,
// which can support macOS, Windows, and Linux operating systems.
// Other operating systems are currently not supported
func Run(arg string, dir string, in ...*bytes.Buffer) (string, error) {
func Run(arg, dir string, in ...*bytes.Buffer) (string, error) {
goos := runtime.GOOS
var cmd *exec.Cmd
switch goos {