Skip to content

Commit 727a787

Browse files
committed
gofmt
1 parent ceccd95 commit 727a787

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

cmd/grt.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010
)
1111

1212
const (
13-
repoHost = "@REPO_HOST@"
14-
repoOrg = "@REPO_ORG@"
15-
repoName = "@REPO_NAME@"
13+
repoHost = "@REPO_HOST@"
14+
repoOrg = "@REPO_ORG@"
15+
repoName = "@REPO_NAME@"
1616
)
17+
1718
var inputFilePath string
1819
var outputFilePath string
1920
var newRepo string

grt.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,35 @@ import (
1010
"github.com/bitfield/script"
1111
)
1212

13-
func ReplaceTokens(inputFilePath, outputFilePath, repoHost, repoOrg, repoName, newRepo string){
13+
// ReplaceTokens replaces tokens in input file and outputs to new file
14+
func ReplaceTokens(inputFilePath, outputFilePath, repoHost, repoOrg, repoName, newRepo string) {
1415
parts := strings.Split(newRepo, "/")
1516
newRepoHost := parts[0]
1617
newRepoOrg := parts[1]
1718
newRepoName := parts[2]
1819
log.Printf("repoHost: %s, repoOrg: %s, repoName: %s, newRepoHost: %s, newRepoOrg: %s, newRepoName: %s\n", repoHost, repoOrg, repoName, newRepoHost, newRepoOrg, newRepoName)
1920
inplace := false
2021

21-
if outputFilePath == ""{
22+
if outputFilePath == "" {
2223
inplace = true
23-
tempFileH, err := ioutil.TempFile(filepath.Dir(inputFilePath),"")
24-
if err != nil{
25-
log.Fatal(err.Error())
24+
tempFileH, err := ioutil.TempFile(filepath.Dir(inputFilePath), "")
25+
if err != nil {
26+
log.Fatal(err.Error())
2627
}
2728
outputFilePath = tempFileH.Name()
2829
}
2930
_, err := script.File(inputFilePath).Replace(repoHost, newRepoHost).Replace(repoOrg, newRepoOrg).Replace(repoName, newRepoName).WriteFile(outputFilePath)
3031

31-
if err != nil{
32-
log.Fatal(err.Error())
32+
if err != nil {
33+
log.Fatal(err.Error())
3334
}
3435

3536
if inplace {
36-
script.File(outputFilePath).Stdout()
37-
log.Printf("Moving %s to %s\n", outputFilePath, inputFilePath)
38-
e :=os.Rename(outputFilePath, inputFilePath)
39-
if e != nil {
40-
log.Fatal(e)
41-
}
37+
script.File(outputFilePath).Stdout()
38+
log.Printf("Moving %s to %s\n", outputFilePath, inputFilePath)
39+
e := os.Rename(outputFilePath, inputFilePath)
40+
if e != nil {
41+
log.Fatal(e)
42+
}
4243
}
4344
}

0 commit comments

Comments
 (0)