Skip to content

Commit

Permalink
remove makefile generation
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Aug 30, 2020
1 parent 5821b73 commit 618bec5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 65 deletions.
7 changes: 4 additions & 3 deletions tools/goctl/api/gogen/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func getParentPackage(dir string) (string, error) {
}

absDir = strings.ReplaceAll(absDir, `\`, `/`)
var rootPath, hasGoMod = goctlutil.FindGoModPath(dir)
rootPath, hasGoMod := goctlutil.FindGoModPath(dir)
if hasGoMod {
return rootPath, nil
}
Expand All @@ -32,7 +32,7 @@ func getParentPackage(dir string) (string, error) {
pos := strings.Index(absDir, parent)
if pos < 0 {
fmt.Printf("%s not in go.mod project path, or not in GOPATH of %s directory\n", absDir, gopath)
var tempPath = filepath.Dir(absDir)
tempPath := filepath.Dir(absDir)
rootPath = absDir[len(tempPath)+1:]
} else {
rootPath = absDir[len(parent)+1:]
Expand Down Expand Up @@ -61,7 +61,7 @@ func writeProperty(writer io.Writer, name, tp, tag, comment string, indent int)
}

func getAuths(api *spec.ApiSpec) []string {
var authNames = collection.NewSet()
authNames := collection.NewSet()
for _, g := range api.Service.Groups {
if value, ok := util.GetAnnotationValue(g.Annotations, "server", "jwt"); ok {
authNames.Add(value)
Expand All @@ -78,5 +78,6 @@ func formatCode(code string) string {
if err != nil {
return code
}

return string(ret)
}
11 changes: 3 additions & 8 deletions tools/goctl/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

func DockerCommand(c *cli.Context) error {
goFile := c.String("go")
namespace := c.String("namespace")
if len(goFile) == 0 || len(namespace) == 0 {
return errors.New("-go and -namespace can't be empty")
if len(goFile) == 0 {
return errors.New("-go can't be empty")
}

if err := gen.GenerateDockerfile(goFile, "-f", "etc/config.json"); err != nil {
return err
}

return gen.GenerateMakefile(goFile, namespace)
return gen.GenerateDockerfile(goFile, "-f", "etc/config.yaml")
}
4 changes: 2 additions & 2 deletions tools/goctl/gen/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func GenerateDockerfile(goFile string, args ...string) error {
relPath, err := util.PathFromGoSrc()
projPath, err := getFilePath(goFile)
if err != nil {
return err
}
Expand All @@ -28,7 +28,7 @@ func GenerateDockerfile(goFile string, args ...string) error {
t := template.Must(template.New("dockerfile").Parse(dockerTemplate))
return t.Execute(out, map[string]string{
"projectName": vars.ProjectName,
"goRelPath": relPath,
"goRelPath": projPath,
"goFile": goFile,
"exeFile": util.FileNameWithoutExt(goFile),
"argument": builder.String(),
Expand Down
26 changes: 26 additions & 0 deletions tools/goctl/gen/filepath.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gen

import (
"errors"
"os"
"path/filepath"

"github.com/tal-tech/go-zero/tools/goctl/util"
)

func getFilePath(file string) (string, error) {
wd, err := os.Getwd()
if err != nil {
return "", err
}

projPath, ok := util.FindGoModPath(filepath.Join(wd, file))
if !ok {
projPath, err = util.PathFromGoSrc()
if err != nil {
return "", errors.New("no go.mod found, or not in GOPATH")
}
}

return projPath, nil
}
52 changes: 0 additions & 52 deletions tools/goctl/gen/makefile.go

This file was deleted.

0 comments on commit 618bec5

Please sign in to comment.