-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go implementation of Piranha #112
Open
crekIron
wants to merge
11
commits into
uber:master
Choose a base branch
from
crekIron:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac2707f
making folder go and transferring code to it
crekIron 7ac72d1
added link of go readme
crekIron 36445bf
changes in readme and test file
crekIron 38274f7
Some changes done.
crekIron fbbc08c
Merge branch 'uber:master' into master
crekIron 47b1f0e
Used flag package to parse the arguments.
crekIron 38680bd
Changes made in src/piranha.go
crekIron b37339e
Incoperated 30% of comments in src/staleFlagCleaner.go
crekIron 6ff77de
Incoperated 70% of comments in src/staleFlagCleaner.go
crekIron 3760732
Merge branch 'uber:master' into master
crekIron 448cabc
Fixed logical error in main.go. Resolves issues in testing on Windows…
crekIron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# PiranhaGo | ||
PiranhaGo is runnable now. | ||
Instructions:- | ||
1. To build the package run `go build -o piranha`. Dependencies will install automatically and they are given in `go.mod` file. | ||
2. Below are the instructions for running for the single file. | ||
``` | ||
Inputs from args | ||
Usage: ./piranha [-h] -p PROPERTIES -s SOURCE_FILE -f STALE_FLAG -mode MODE_NAME [-o OUTPUT] | ||
Required arguments: | ||
-s SOURCE_FILE: Path of the file to be refactored. | ||
-p PROPERTIES: Configuration file (json format) for Piranha. | ||
-f STALE_FLAG: Name of the stale flag. | ||
-mode MODE_NAME: If MODE_NAME=treated, then flag is treated, | ||
otherwise MODE_NAME=control, it is control. | ||
Optional arguments: | ||
-h: Show the options and exit. | ||
-o OUTPUT: Destination of the refactored output from piranha. If -o is not provided, then the source file is updated in place. | ||
``` | ||
3. To do a test run, run piranha on `example/testExample.go`. Run `./piranha -p properties.json -s ./example/testExample.go -o ./example/treatedExample.go -f staleFlag -mode control` command in root directory. You will get your refactored file as `/example/treatedExample.go`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright (c) 2021 Uber Technologies, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
|
||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
|
||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
express or implied. See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package testfiles | ||
|
||
import "fmt" | ||
|
||
func testExpressions(ge GoExamples) { | ||
var x, y bool = false, false | ||
|
||
if ge.flagMthds.treatedBehaviour(staleFlag) || x { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) || x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) || x`") | ||
} | ||
|
||
if ge.flagMthds.treatedBehaviour(staleFlag) && x { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && x`") | ||
} | ||
|
||
if ge.flagMthds.treatedBehaviour(staleFlag) && (x || y) { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x || y)`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x || y)`") | ||
} | ||
|
||
if ge.flagMthds.treatedBehaviour(staleFlag) && (x && y) { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x && y)`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x && y)`") | ||
} | ||
|
||
if ge.flagMthds.treatedBehaviour(staleFlag) && y == x { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && y == x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && y == x`") | ||
} | ||
|
||
if ge.flagMthds.controlBehaviour(staleFlag) || y == x { | ||
fmt.Println("then-braanch of `ge.flagMthds.controlBehaviour(staleFlag) || y == x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.controlBehaviour(staleFlag) || y == x`") | ||
} | ||
|
||
if ge.flagMthds.controlBehaviour(staleFlag) && y && x { | ||
fmt.Println("then-branch of `ge.flagMthds.controlBehaviour(staleFlag) && y && x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.controlBehaviour(staleFlag) && y && x`") | ||
} | ||
|
||
if ge.flagMthds.controlBehaviour(staleFlag) || y || x { | ||
fmt.Println("then-braanch of `ge.flagMthds.controlBehaviour(staleFlag) || y || x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.controlBehaviour(staleFlag) || y || x`") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright (c) 2021 Uber Technologies, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
|
||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
|
||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
express or implied. See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package testfiles | ||
|
||
import "fmt" | ||
|
||
func testExpressions(ge GoExamples) { | ||
var x, y bool = false, false | ||
|
||
if x { | ||
fmt.Println("then-branch of `ge.flagMthds.treatedBehaviour(staleFlag) || x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) || x`") | ||
} | ||
|
||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && x`") | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x || y)`") | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && (x && y)`") | ||
fmt.Println("else-branch of `ge.flagMthds.treatedBehaviour(staleFlag) && y == x`") | ||
fmt.Println("then-braanch of `ge.flagMthds.controlBehaviour(staleFlag) || y == x`") | ||
|
||
if y && x { | ||
fmt.Println("then-branch of `ge.flagMthds.controlBehaviour(staleFlag) && y && x`") | ||
} else { | ||
fmt.Println("else-branch of `ge.flagMthds.controlBehaviour(staleFlag) && y && x`") | ||
} | ||
|
||
fmt.Println("then-braanch of `ge.flagMthds.controlBehaviour(staleFlag) || y || x`") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/PiranhaGo | ||
|
||
go 1.16 | ||
|
||
require github.com/dave/dst v0.26.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY= | ||
github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU= | ||
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ= | ||
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= | ||
github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8= | ||
github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA= | ||
github.com/google/pprof v0.0.0-20181127221834-b4f47329b966/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= | ||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | ||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= | ||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= | ||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||
golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= | ||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 h1:MeC2gMlMdkd67dn17MEby3rGXRxZtWeiRXOnISfTQ74= | ||
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= | ||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright (c) 2021 Uber Technologies, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
|
||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
|
||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
express or implied. See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/PiranhaGo/src" | ||
) | ||
|
||
func main() { | ||
var sourceFile, configFile, flagName, outputFileName, modeName string | ||
var isTreated = false | ||
|
||
// get configFile | ||
flag.StringVar(&configFile, "p", "PROPERTIES", "Configuration file (json format) for Piranha.") | ||
// get sourceFile | ||
flag.StringVar(&sourceFile, "s", "SOURCE_FILE", "Path of the file to be refactored.") | ||
// get flagName | ||
flag.StringVar(&flagName, "f", "STALE_FLAG", "Name of the stale flag.") | ||
// check treatedMode | ||
flag.StringVar(&modeName, "mode", "MODE_NAME", "If MODE_NAME=treated, then flag is treated, otherwise MODE_NAME=control, it is control.") | ||
if modeName == "treated" { | ||
isTreated = true | ||
} | ||
// get outputFileName | ||
flag.StringVar(&outputFileName, "o", "OUTPUT", "Destination of the refactored output from piranha. If -o is not provided, then the source file is updated in place.") | ||
|
||
flag.Parse() | ||
|
||
|
||
src.RunPiranha(sourceFile, configFile, flagName, outputFileName, isTreated) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"methodProperties": [ | ||
{ | ||
"methodName": "treatedBehaviour", | ||
"flagType": "treated", | ||
"argumentIndex": 0 | ||
}, | ||
{ | ||
"methodName": "controlBehaviour", | ||
"flagType": "control", | ||
"argumentIndex": 0 | ||
}, | ||
{ | ||
"methodName": "commonBehaviour", | ||
"flagType": "treated", | ||
"argumentIndex": 1 | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Copyright (c) 2021 Uber Technologies, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
|
||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
|
||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
express or implied. See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package src | ||
|
||
import ( | ||
"fmt" | ||
"go/parser" | ||
"go/token" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/dave/dst" | ||
"github.com/dave/dst/decorator" | ||
) | ||
|
||
/* | ||
Inputs from args | ||
Usage: ./piranha [-h] -p PROPERTIES -s SOURCE_FILE -f STALE_FLAG -mode MODE_NAME [-o OUTPUT] | ||
Required arguments: | ||
-s SOURCE_FILE: Path of the file to be refactored. | ||
-p PROPERTIES: Configuration file (json format) for Piranha. | ||
-f STALE_FLAG: Name of the stale flag. | ||
-mode MODE_NAME: If MODE_NAME=treated, then flag is treated, | ||
otherwise MODE_NAME=control, it is control. | ||
Optional arguments: | ||
-h: Show the options and exit. | ||
-o OUTPUT: Destination of the refactored output from piranha. If -o is not provided, then the source file is updated in place. | ||
*/ | ||
func reportArgumentError(arg string) { | ||
switch arg { | ||
case "configFileSuffix": | ||
fmt.Println("Please provide configuration file of json format.") | ||
case "sourceFileSuffix": | ||
fmt.Println("Please provide source file of go format.") | ||
case "flagName": | ||
fmt.Println("Please provide a flag.") | ||
case "configFile": | ||
fmt.Println("Please provide a config file. See README for more instructions.") | ||
case "sourceFile": | ||
fmt.Println("Please provide a source file that is to be refactored.") | ||
} | ||
fmt.Println("For more info, run ./piranha -h.") | ||
} | ||
|
||
// RunPiranha : the main function for the piranha tool | ||
func RunPiranha(sourceFile string, configFile string, flagName string, outputFileName string, isTreated bool) { | ||
if flagName == "STALE_FLAG" { | ||
reportArgumentError("flagName") | ||
return | ||
} | ||
if sourceFile == "SOURCE_FILE" { | ||
reportArgumentError("sourceFile") | ||
return | ||
} | ||
if configFile == "PROPERTIES" { | ||
reportArgumentError("configFile") | ||
return | ||
} | ||
|
||
if !strings.HasSuffix(configFile, ".json") { | ||
reportArgumentError("sourceFileSuffix") | ||
return | ||
} | ||
|
||
if !strings.HasSuffix(sourceFile, ".go") { | ||
reportArgumentError("sourceFileSuffix") | ||
return | ||
} | ||
|
||
fs := token.NewFileSet() | ||
parsed, err := decorator.ParseFile(fs, sourceFile, nil, parser.ParseComments) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
var cleaner staleFlagCleaner | ||
err = cleaner.init(configFile, flagName, isTreated) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
newRoot := cleaner.run(parsed) | ||
|
||
if outputFileName == "" { | ||
outputFileName = sourceFile | ||
} | ||
outputFile, _ := os.Create(outputFileName) | ||
/* | ||
Here we are typecasting newRoot to dst.File. It is safe because the root of AST | ||
always starts with the dst.File type. | ||
*/ | ||
decorator.Fprint(outputFile, newRoot.(*dst.File)) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be excuted after L40 flag.Parse().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out. I changed it now.