Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 9756804

Browse files
author
Michael Kraus
committed
Retain argument order, do not use golang maps
1 parent b8f5767 commit 9756804

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

check_nsc_web.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var usage = `
3939
4040
You should have received a copy of the GNU General Public License
4141
along with this program. If not, see <http://www.gnu.org/licenses/>.
42-
42+
4343
Example:
4444
check_nsc_web -p "password" -u "https://<SERVER_RUNNING_NSCLIENT>:8443" check_cpu
4545
@@ -137,24 +137,26 @@ func main() {
137137
urlStruct.Path += "/query/" + flag.Arg(0)
138138
} else {
139139
urlStruct.Path += "/query/" + flag.Arg(0)
140-
parameters := url.Values{}
140+
var param bytes.Buffer
141141
for i, a := range flag.Args() {
142142
if i == 0 {
143143
continue
144+
} else if i > 1 {
145+
param.WriteString("&")
144146
}
147+
145148
p := strings.SplitN(a, "=", 2)
146149
if len(p) == 1 {
147-
// FIXME it is unclear if a trailing "=" e.g. on show-all can lead to errors
148-
parameters.Add(p[0], "")
150+
param.WriteString(url.QueryEscape(p[0]))
149151
} else {
150-
parameters.Add(p[0], p[1])
152+
param.WriteString(url.QueryEscape(p[0]) + "=" + url.QueryEscape(p[1]))
151153
}
152154
if err != nil {
153155
fmt.Println("UNKNOWN: " + err.Error())
154156
os.Exit(3)
155157
}
156158
}
157-
urlStruct.RawQuery = parameters.Encode()
159+
urlStruct.RawQuery = param.String()
158160
}
159161

160162
var hTransport = &http.Transport{

0 commit comments

Comments
 (0)