1
// Copyright 2013 Canonical Ltd. This software is licensed under the
2
// GNU Lesser General Public License version 3 (see the file COPYING).
12
// b64 is shorthand for base64-encoding a string.
13
func b64(s string) string {
14
return base64.StdEncoding.EncodeToString([]byte(s))
17
// A Reader and ReadCloser that EOFs immediately.
18
var Empty io.ReadCloser = makeResponseBody("")
20
// BoolToString represents a boolean value as a string ("true" or "false").
21
func BoolToString(v bool) string {
22
return fmt.Sprintf("%t", v)
25
// StringToBool parses a string containing a boolean (case-insensitive).
26
func StringToBool(v string) (b bool) {
27
items, err := fmt.Sscanf(v, "%t", &b)
28
if err != nil || items != 1 {
29
panic(fmt.Errorf("can't convert '%s' to a bool", v))