| Age | Commit message (Collapse) | Author |
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
|
|
Shell quote is a hell of complex. For example, one can write
shell that execute command that contains quote,
sh -c "psql -c 'CREATE ... IDENTIFIED BY PASSWORD '\''pass'\'''"
or to simplify,
sh -c "psql -c \"CREATE ... IDENTIFIED BY PASSWORD 'pass'\""
|
|
This reverts commit 1adcb7901dc62ef288cf82f504f8fae30068b21b.
Reason for revert:
Given the following string statement: `sh -c "echo a"`, the
ParseCommandArgs will return
cmd: "sh"
args: []string{`-c`, `"echo a"`}
If we pass this to exec.Command(cmd, args) and call Run, it will return
an error
sh: line 1: echo a: command not found
|
|
Previously, if we pass `a "b c"` to ParseCommanArgs, it will return
`a` as command and `b c` in args.
Now, it will return `"b c"` in args with double quotes.
|
|
Given the following string "cmd /a\ b" to ParseCommandArgs now it should
return "cmd" and ["/a b"] not ["/a\", "b"], because the space after a
is escaped using backslash.
|
|
New extension to standard package is function ParseCommandArgs() that
receive input as string and return itas command and list of arguments.
Unlike strings.Fields() which only separated the field by space,
ParseCommandArgs can detect possible single, double, or back quotes.
Another extension is Run() function that accept the string command
to be executed and their standard output and error.
|