~ubuntu-branches/ubuntu/saucy/juju-core/saucy-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/gwacl/helpers_misc_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Canonical Ltd.  This software is licensed under the
 
2
// GNU Lesser General Public License version 3 (see the file COPYING).
 
3
 
 
4
package gwacl
 
5
 
 
6
import (
 
7
    "encoding/base64"
 
8
    "fmt"
 
9
    "io"
 
10
)
 
11
 
 
12
// b64 is shorthand for base64-encoding a string.
 
13
func b64(s string) string {
 
14
    return base64.StdEncoding.EncodeToString([]byte(s))
 
15
}
 
16
 
 
17
// A Reader and ReadCloser that EOFs immediately.
 
18
var Empty io.ReadCloser = makeResponseBody("")
 
19
 
 
20
// BoolToString represents a boolean value as a string ("true" or "false").
 
21
func BoolToString(v bool) string {
 
22
    return fmt.Sprintf("%t", v)
 
23
}
 
24
 
 
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))
 
30
    }
 
31
    return
 
32
}