gofmt -s -w .

Signed-off-by: Phus Lu <phus.lu@citrix.com>
This commit is contained in:
Phus Lu 2016-07-15 09:55:04 -07:00
parent a850d3d4f0
commit 059707af53
25 changed files with 337 additions and 343 deletions

View File

@ -4,8 +4,8 @@ import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
gossh "golang.org/x/crypto/ssh"
xsclient "github.com/xenserver/go-xenserver-client"
gossh "golang.org/x/crypto/ssh"
"log"
"time"
)

View File

@ -37,7 +37,7 @@ func init() {
}
ops := make([]string, 0, len(constraintOperators))
for k, _ := range constraintOperators {
for k := range constraintOperators {
ops = append(ops, regexp.QuoteMeta(k))
}

View File

@ -6,14 +6,14 @@ import (
)
type Document struct {
root *Element
root *Element
PrettyPrint bool
Indentation string
DocType bool
DocType bool
}
func CreateDocument() *Document {
return &Document{ PrettyPrint: false, Indentation: " ", DocType: true }
return &Document{PrettyPrint: false, Indentation: " ", DocType: true}
}
func (doc *Document) SetRoot(node *Element) {
@ -26,10 +26,10 @@ func (doc *Document) String() string {
if doc.DocType {
fmt.Fprintln(&b, `<?xml version="1.0" encoding="utf-8" ?>`)
}
if doc.root != nil {
doc.root.Bytes(&b, doc.PrettyPrint, doc.Indentation, 0)
}
return string(b.Bytes())
}

View File

@ -1,9 +1,9 @@
package dom
import (
"bytes"
"encoding/xml"
"fmt"
"bytes"
)
type Attr struct {
@ -12,20 +12,20 @@ type Attr struct {
}
type Element struct {
name xml.Name
children []*Element
parent *Element
content string
name xml.Name
children []*Element
parent *Element
content string
attributes []*Attr
namespaces []*Namespace
document *Document
document *Document
}
func CreateElement(n string) *Element {
element := &Element { name: xml.Name { Local: n } }
element := &Element{name: xml.Name{Local: n}}
element.children = make([]*Element, 0, 5)
element.attributes = make([]*Attr, 0, 10)
element.namespaces = make([]*Namespace, 0, 10)
element.namespaces = make([]*Namespace, 0, 10)
return element
}
@ -59,7 +59,7 @@ func (node *Element) RemoveChild(child *Element) *Element {
func (node *Element) SetAttr(name string, value string) *Element {
// namespaces?
attr := &Attr{ Name: xml.Name { Local: name }, Value: value }
attr := &Attr{Name: xml.Name{Local: name}, Value: value}
node.attributes = append(node.attributes, attr)
return node
}
@ -67,18 +67,18 @@ func (node *Element) SetAttr(name string, value string) *Element {
func (node *Element) SetParent(parent *Element) *Element {
node.parent = parent
return node
}
}
func (node *Element) SetContent(content string) *Element {
node.content = content
return node
}
}
// Add a namespace declaration to this node
func (node *Element) DeclareNamespace(ns Namespace) *Element {
// check if we already have it
prefix := node.namespacePrefix(ns.Uri)
if prefix == ns.Prefix {
if prefix == ns.Prefix {
return node
}
// add it
@ -94,7 +94,7 @@ func (node *Element) SetNamespace(prefix string, uri string) {
resolved := node.namespacePrefix(uri)
if resolved == "" {
// we couldn't find the namespace, let's declare it at this node
node.namespaces = append(node.namespaces, &Namespace { Prefix: prefix, Uri: uri })
node.namespaces = append(node.namespaces, &Namespace{Prefix: prefix, Uri: uri})
}
node.name.Space = uri
}
@ -102,19 +102,19 @@ func (node *Element) SetNamespace(prefix string, uri string) {
func (node *Element) Bytes(out *bytes.Buffer, indent bool, indentType string, level int) {
empty := len(node.children) == 0 && node.content == ""
content := node.content != ""
// children := len(node.children) > 0
// ns := len(node.namespaces) > 0
// attrs := len(node.attributes) > 0
// children := len(node.children) > 0
// ns := len(node.namespaces) > 0
// attrs := len(node.attributes) > 0
indentStr := ""
nextLine := ""
if indent {
nextLine = "\n"
for i := 0; i < level; i++ {
indentStr += indentType
indentStr += indentType
}
}
if node.name.Local != "" {
if len(node.name.Space) > 0 {
// first find if ns has been declared, otherwise
@ -124,7 +124,7 @@ func (node *Element) Bytes(out *bytes.Buffer, indent bool, indentType string, le
fmt.Fprintf(out, "%s<%s", indentStr, node.name.Local)
}
}
// declared namespaces
for _, v := range node.namespaces {
prefix := node.namespacePrefix(v.Uri)
@ -140,7 +140,7 @@ func (node *Element) Bytes(out *bytes.Buffer, indent bool, indentType string, le
fmt.Fprintf(out, ` %s="%s"`, v.Name.Local, v.Value)
}
}
// close tag
if empty {
fmt.Fprintf(out, "/>%s", nextLine)
@ -148,20 +148,20 @@ func (node *Element) Bytes(out *bytes.Buffer, indent bool, indentType string, le
if content {
out.WriteRune('>')
} else {
fmt.Fprintf(out, ">%s", nextLine)
fmt.Fprintf(out, ">%s", nextLine)
}
}
if len(node.children) > 0 {
for _, child := range node.children {
child.Bytes(out, indent, indentType, level + 1)
child.Bytes(out, indent, indentType, level+1)
}
} else if node.content != "" {
//val := []byte(node.content)
//xml.EscapeText(out, val)
out.WriteString(node.content)
}
if !empty && len(node.name.Local) > 0 {
var indentation string
if content {
@ -192,7 +192,6 @@ func (node *Element) namespacePrefix(uri string) string {
return node.parent.namespacePrefix(uri)
}
func (node *Element) String() string {
var b bytes.Buffer
node.Bytes(&b, false, "", 0)

View File

@ -73,8 +73,8 @@
//
// To use xmlpath with namespaces, it is required to give the supported set of namespace
// when compiling:
//
//
//
//
// var namespaces = []xmlpath.Namespace {
// { "s", "http://www.w3.org/2003/05/soap-envelope" },
// { "a", "http://schemas.xmlsoap.org/ws/2004/08/addressing" },
@ -90,6 +90,6 @@
// if value, ok := path.String(root); ok {
// fmt.Println("Found:", value)
// }
//
//
package xmlpath

View File

@ -372,7 +372,7 @@ func MustCompile(path string) *Path {
// Compile returns the compiled path.
func Compile(path string) (*Path, error) {
c := pathCompiler{path, 0, []Namespace{} }
c := pathCompiler{path, 0, []Namespace{}}
if path == "" {
return nil, c.errorf("empty path")
}
@ -397,9 +397,9 @@ func CompileWithNamespace(path string, ns []Namespace) (*Path, error) {
}
type pathCompiler struct {
path string
i int
ns []Namespace
path string
i int
ns []Namespace
}
func (c *pathCompiler) errorf(format string, args ...interface{}) error {
@ -575,14 +575,14 @@ func (c *pathCompiler) parseLiteral() (string, error) {
if !c.skipByteFind('"') {
return "", fmt.Errorf(`missing '"'`)
}
return c.path[mark:c.i-1], nil
return c.path[mark : c.i-1], nil
}
if c.skipByte('\'') {
mark := c.i
if !c.skipByteFind('\'') {
return "", fmt.Errorf(`missing "'"`)
}
return c.path[mark:c.i-1], nil
return c.path[mark : c.i-1], nil
}
return "", errNoLiteral
}
@ -611,7 +611,7 @@ func (c *pathCompiler) skipByte(b byte) bool {
func (c *pathCompiler) skipByteFind(b byte) bool {
for i := c.i; i < len(c.path); i++ {
if c.path[i] == b {
c.i = i+1
c.i = i + 1
return true
}
}

View File

@ -125,7 +125,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
// Create the "." and ".." entries
cluster.entries = []*DirectoryClusterEntry{
&DirectoryClusterEntry{
{
accessTime: t,
attr: AttrDirectory,
cluster: start,
@ -133,7 +133,7 @@ func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryClu
name: ".",
writeTime: t,
},
&DirectoryClusterEntry{
{
accessTime: t,
attr: AttrDirectory,
cluster: parent,
@ -159,8 +159,8 @@ func NewFat16RootDirectoryCluster(bs *BootSectorCommon, label string) (*Director
// Create the volume ID entry
result.entries[0] = &DirectoryClusterEntry{
attr: AttrVolumeId,
name: label,
attr: AttrVolumeId,
name: label,
cluster: 0,
}

View File

@ -30,11 +30,11 @@ func generateShortName(longName string, used []string) (string, error) {
if dotIdx == -1 {
dotIdx = len(longName)
} else {
ext = longName[dotIdx+1 : len(longName)]
ext = longName[dotIdx+1:]
}
ext = cleanShortString(ext)
ext = ext[0:len(ext)]
ext = ext[0:]
rawName := longName[0:dotIdx]
name := cleanShortString(rawName)
simpleName := fmt.Sprintf("%s.%s", name, ext)

View File

@ -653,7 +653,7 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value)
if !rawMapVal.IsValid() {
// Do a slower search by iterating over each key and
// doing case-insensitive search.
for dataValKey, _ := range dataValKeys {
for dataValKey := range dataValKeys {
mK, ok := dataValKey.Interface().(string)
if !ok {
// Not a string key
@ -701,7 +701,7 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value)
if d.config.ErrorUnused && len(dataValKeysUnused) > 0 {
keys := make([]string, 0, len(dataValKeysUnused))
for rawKey, _ := range dataValKeysUnused {
for rawKey := range dataValKeysUnused {
keys = append(keys, rawKey.(string))
}
sort.Strings(keys)
@ -716,7 +716,7 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value)
// Add the unused keys to the list of unused keys if we're tracking metadata
if d.config.Metadata != nil {
for rawKey, _ := range dataValKeysUnused {
for rawKey := range dataValKeysUnused {
key := rawKey.(string)
if name != "" {
key = fmt.Sprintf("%s.%s", name, key)

View File

@ -124,7 +124,7 @@ func (d *DownloadClient) Get() (string, error) {
// Remove forward slash on absolute Windows file URLs before processing
if runtime.GOOS == "windows" && len(finalPath) > 0 && finalPath[0] == '/' {
finalPath = finalPath[1:len(finalPath)]
finalPath = finalPath[1:]
}
// Keep track of the source so we can make sure not to delete this later
sourcePath = finalPath

View File

@ -175,7 +175,7 @@ func (c *comm) DownloadDir(src string, dst string, excl []string) error {
switch fi[0] {
case '\x01', '\x02':
return fmt.Errorf("%s", fi[1:len(fi)])
return fmt.Errorf("%s", fi[1:])
case 'C', 'D':
break
default:
@ -591,7 +591,7 @@ func (c *comm) scpDownloadSession(path string, output io.Writer) error {
switch fi[0] {
case '\x01', '\x02':
return fmt.Errorf("%s", fi[1:len(fi)])
return fmt.Errorf("%s", fi[1:])
case 'C':
case 'D':
return fmt.Errorf("remote file is directory")

View File

@ -18,7 +18,7 @@ func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallen
// Just send the password back for all questions
answers := make([]string, len(questions))
for i, _ := range answers {
for i := range answers {
answers[i] = string(password)
}

View File

@ -87,7 +87,7 @@ func NewCore(c *CoreConfig) (*Core, error) {
// BuildNames returns the builds that are available in this configured core.
func (c *Core) BuildNames() []string {
r := make([]string, 0, len(c.builds))
for n, _ := range c.builds {
for n := range c.builds {
r = append(r, n)
}
sort.Strings(r)

View File

@ -291,7 +291,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
// so they dont' block since it is an io.Pipe
defer func() {
go func() {
for _ = range linesCh {
for range linesCh {
}
}()
}()

View File

@ -107,7 +107,7 @@ func (t *Template) Validate() error {
}
// Validate overrides
for name, _ := range p.Override {
for name := range p.Override {
if _, ok := t.Builders[name]; !ok {
err = multierror.Append(err, fmt.Errorf(
"provisioner %d: override '%s' doesn't exist",

View File

@ -16,7 +16,7 @@ import (
"regexp"
)
// The UUID reserved variants.
// The UUID reserved variants.
const (
ReservedNCS byte = 0x80
ReservedRFC4122 byte = 0x40

View File

@ -6,12 +6,10 @@ type pslist struct {
type psobject struct {
Properties []psproperty `xml:"Property"`
Value string `xml:",innerxml"`
Value string `xml:",innerxml"`
}
type psproperty struct {
Name string `xml:"Name,attr"`
Value string `xml:",innerxml"`
}

View File

@ -79,7 +79,7 @@ func parseParams(rawParams string) (csparams, error) {
// Test to see of all the required parameters are set
func verifyRequiredParams(cs *CloudStackClient, cmd *command, rawParams *csparams) error {
params := *rawParams
for key, _ := range cmd.RequiredParams {
for key := range cmd.RequiredParams {
if _, found := params[key]; !found {
if _, found := params[strings.TrimSuffix(key, "id")]; found {
if err := convertToId(cs, strings.TrimSuffix(key, "id"), &params); err != nil {
@ -99,7 +99,7 @@ func verifyAllUsedParams(cs *CloudStackClient, cmd *command, rawParams *csparams
// Make a slice of keys to walk over, as we could be changing the params value
// during the loop, if we find a key that needs to be resolved to an id
keys := []string{}
for key, _ := range params {
for key := range params {
keys = append(keys, key)
}
for _, key := range keys {

View File

@ -135,15 +135,15 @@ func unmarshalId(key string, rawJSON json.RawMessage) (string, error) {
// ok so this isn't good, but it doens't mean the end of the world
// go find that response key and see if it pattern matches the input key
for responseKey, value := range result {
if strings.Contains (strings.ToLower(key), strings.ToLower(responseKey) ) {
if strings.Contains(strings.ToLower(key), strings.ToLower(responseKey)) {
found = true
key = responseKey
rawResult = value
break
}
}
if (!found) {
if !found {
return "", fmt.Errorf("Unable to find key '%s' in result: %v", key, result)
}
}
@ -158,7 +158,6 @@ func unmarshalId(key string, rawJSON json.RawMessage) (string, error) {
return id[0].Id, nil
}
// this one is exported to allow for callers to readily obtain the real response data
func UnmarshalResponse(key string, rawJSON json.RawMessage) (json.RawMessage, error) {
@ -180,15 +179,15 @@ func UnmarshalResponse(key string, rawJSON json.RawMessage) (json.RawMessage, er
// ok so this isn't good, but it doens't mean the end of the world
// go find that response key and see if it pattern matches the input key
for responseKey, value := range result {
if strings.Contains (strings.ToLower(key), strings.ToLower(responseKey) ) {
if strings.Contains(strings.ToLower(key), strings.ToLower(responseKey)) {
found = true
key = responseKey
rawResult = value
break
}
}
if (!found) {
if !found {
return nil, fmt.Errorf("Unable to find key '%s' in result: %v", key, result)
}
}
@ -196,7 +195,6 @@ func UnmarshalResponse(key string, rawJSON json.RawMessage) (json.RawMessage, er
return rawResult, nil
}
func unmarshalAsyncResponse(rawJSON json.RawMessage) (*asyncResult, error) {
rawResponse, err := getRawValue(rawJSON)
if err != nil {

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT license found in the LICENSE file.
/*
High Performance, Feature-Rich Idiomatic Go codec/encoding library for
High Performance, Feature-Rich Idiomatic Go codec/encoding library for
binc, msgpack, cbor, json.
Supported Serialization formats are:
@ -11,7 +11,7 @@ Supported Serialization formats are:
- binc: http://github.com/ugorji/binc
- cbor: http://cbor.io http://tools.ietf.org/html/rfc7049
- json: http://json.org http://tools.ietf.org/html/rfc7159
- simple:
- simple:
To install:
@ -19,7 +19,7 @@ To install:
This package understands the 'unsafe' tag, to allow using unsafe semantics:
- When decoding into a struct, you need to read the field name as a string
- When decoding into a struct, you need to read the field name as a string
so you can find the struct field it is mapped to.
Using `unsafe` will bypass the allocation and copying overhead of []byte->string conversion.
@ -38,9 +38,9 @@ Rich Feature Set includes:
- Very High Performance.
Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X.
- Multiple conversions:
Package coerces types where appropriate
Package coerces types where appropriate
e.g. decode an int in the stream into a float, etc.
- Corner Cases:
- Corner Cases:
Overflows, nil maps/slices, nil values in streams are handled correctly
- Standard field renaming via tags
- Support for omitting empty fields during an encoding
@ -56,7 +56,7 @@ Rich Feature Set includes:
- Fast (no-reflection) encoding/decoding of common maps and slices
- Code-generation for faster performance.
- Support binary (e.g. messagepack, cbor) and text (e.g. json) formats
- Support indefinite-length formats to enable true streaming
- Support indefinite-length formats to enable true streaming
(for formats which support it e.g. json, cbor)
- Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes.
This mostly applies to maps, where iteration order is non-deterministic.
@ -68,12 +68,12 @@ Rich Feature Set includes:
- Encode/Decode from/to chan types (for iterative streaming support)
- Drop-in replacement for encoding/json. `json:` key in struct tag supported.
- Provides a RPC Server and Client Codec for net/rpc communication protocol.
- Handle unique idiosynchracies of codecs e.g.
- For messagepack, configure how ambiguities in handling raw bytes are resolved
- For messagepack, provide rpc server/client codec to support
- Handle unique idiosynchracies of codecs e.g.
- For messagepack, configure how ambiguities in handling raw bytes are resolved
- For messagepack, provide rpc server/client codec to support
msgpack-rpc protocol defined at:
https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
Extension Support
Users can register a function to handle the encoding or decoding of

File diff suppressed because it is too large Load Diff

View File

@ -172,4 +172,3 @@ if {{var "l"}} == 0 {
*{{ .Varname }} = {{var "v"}}
}{{end}}
`

View File

@ -221,7 +221,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
}
// use a sorted set of im keys, so that we can get consistent output
imKeys := make([]string, 0, len(x.im))
for k, _ := range x.im {
for k := range x.im {
imKeys = append(imKeys, k)
}
sort.Strings(imKeys)

View File

@ -322,7 +322,7 @@ func (c *CertChecker) CheckCert(principal string, cert *Certificate) error {
return fmt.Errorf("ssh: certicate serial %d revoked", cert.Serial)
}
for opt, _ := range cert.CriticalOptions {
for opt := range cert.CriticalOptions {
// sourceAddressCriticalOption will be enforced by
// serverAuthenticate
if opt == sourceAddressCriticalOption {

View File

@ -383,7 +383,7 @@ func (s *Session) Wait() error {
s.stdinPipeWriter.Close()
}
var copyError error
for _ = range s.copyFuncs {
for range s.copyFuncs {
if err := <-s.errors; err != nil && copyError == nil {
copyError = err
}