Skip to content

Commit b1dd884

Browse files
authored
Merge pull request #112 from kcmvp/deps
#109: code clean up
2 parents 1e55d87 + 3a6d949 commit b1dd884

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

cmd/gbc/artifact/project.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package artifact
22

33
import (
4-
"bufio"
54
"errors"
65
"fmt"
76
"github.com/fatih/color" //nolint
@@ -128,22 +127,6 @@ func (project *Project) Target() string {
128127
return target
129128
}
130129

131-
// sourceFileInPkg return all go source file in a package
132-
func (project *Project) sourceFileInPkg(pkg string) ([]string, error) {
133-
_ = os.Chdir(project.Root())
134-
cmd := exec.Command("go", "list", "-f", fmt.Sprintf("{{if eq .Name \"%s\"}}{{.Dir}}{{end}}", pkg), "./...")
135-
output, _ := cmd.Output()
136-
scanner := bufio.NewScanner(strings.NewReader(string(output)))
137-
var dirs []string
138-
for scanner.Scan() {
139-
line := strings.TrimSpace(scanner.Text())
140-
if len(line) > 0 {
141-
dirs = append(dirs, line)
142-
}
143-
}
144-
return dirs, nil
145-
}
146-
147130
func (project *Project) MainFiles() []string {
148131
return lo.FilterMap(project.pkgs, func(pkg *packages.Package, _ int) (string, bool) {
149132
if pkg.Name != "main" {

cmd/gbc/command/root.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,22 @@ func usageTemplate() string {
4242
return usage
4343
}
4444

45-
func parseArtifacts(cmd *cobra.Command, args []string, name string) (gjson.Result, error) {
45+
func parseArtifacts(cmd *cobra.Command, args []string, section string) (gjson.Result, error) {
4646
var result gjson.Result
4747
var data []byte
4848
var err error
4949
if test, uqf := utils.TestCaller(); test {
5050
data, err = os.ReadFile(filepath.Join(artifact.CurProject().Root(), "target", uqf, "config.json"))
5151
} else {
52-
path.Join()
5352
data, err = resources.ReadFile(path.Join(resourceDir, "config.json"))
5453
}
5554
if err != nil {
5655
return result, err
5756
}
5857
key := strings.ReplaceAll(cmd.CommandPath(), " ", "_")
59-
result = gjson.GetBytes(data, fmt.Sprintf("%s.%s", key, name))
58+
result = gjson.GetBytes(data, fmt.Sprintf("%s.%s", key, section))
6059
if !result.Exists() {
61-
result = gjson.GetBytes(data, fmt.Sprintf("%s_%s.%s", key, strings.Join(args, "_"), name))
60+
result = gjson.GetBytes(data, fmt.Sprintf("%s_%s.%s", key, strings.Join(args, "_"), section))
6261
}
6362
return result, nil
6463
}

0 commit comments

Comments
 (0)