Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
niemeyer committed Jun 17, 2013
1 parent c9c3ede commit 406b882
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 114 deletions.
20 changes: 10 additions & 10 deletions auth.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -91,13 +91,13 @@ func (socket *mongoSocket) resetNonce() {
op.limit = -1
op.replyFunc = func(err error, reply *replyOp, docNum int, docData []byte) {
if err != nil {
socket.kill(errors.New("getNonce: " + err.Error()), true)
socket.kill(errors.New("getNonce: "+err.Error()), true)
return
}
result := &getNonceResult{}
err = bson.Unmarshal(docData, &result)
if err != nil {
socket.kill(errors.New("Failed to unmarshal nonce: " + err.Error()), true)
socket.kill(errors.New("Failed to unmarshal nonce: "+err.Error()), true)
return
}
debugf("Socket %p to %s: nonce unmarshalled: %#v", socket, socket.addr, result)
Expand Down Expand Up @@ -125,7 +125,7 @@ func (socket *mongoSocket) resetNonce() {
}
err := socket.Query(op)
if err != nil {
socket.kill(errors.New("resetNonce: " + err.Error()), true)
socket.kill(errors.New("resetNonce: "+err.Error()), true)
}
}

Expand Down
36 changes: 18 additions & 18 deletions auth_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -27,8 +27,8 @@
package mgo_test

import (
. "launchpad.net/gocheck"
"labix.org/v2/mgo"
. "launchpad.net/gocheck"
"sync"
)

Expand Down Expand Up @@ -146,17 +146,17 @@ func (s *S) TestAuthUpsertUser(c *C) {
ruser := &mgo.User{
Username: "myruser",
Password: "mypass",
Roles: []mgo.Role{mgo.RoleRead},
Roles: []mgo.Role{mgo.RoleRead},
}
rwuser := &mgo.User{
Username: "myrwuser",
Password: "mypass",
Roles: []mgo.Role{mgo.RoleReadWrite},
Roles: []mgo.Role{mgo.RoleReadWrite},
}
rwuserother := &mgo.User{
Username: "myrwuser",
Username: "myrwuser",
UserSource: "mydb",
Roles: []mgo.Role{mgo.RoleRead},
Roles: []mgo.Role{mgo.RoleRead},
}

err = mydb.UpsertUser(ruser)
Expand Down Expand Up @@ -209,8 +209,8 @@ func (s *S) TestAuthUpserUserOtherDBRoles(c *C) {
c.Assert(err, IsNil)

ruser := &mgo.User{
Username: "myruser",
Password: "mypass",
Username: "myruser",
Password: "mypass",
OtherDBRoles: map[string][]mgo.Role{"mydb": []mgo.Role{mgo.RoleRead}},
}

Expand Down Expand Up @@ -243,9 +243,9 @@ func (s *S) TestAuthUpserUserUnsetFields(c *C) {

// Insert a user with most fields set.
user := &mgo.User{
Username: "myruser",
Password: "mypass",
Roles: []mgo.Role{mgo.RoleRead},
Username: "myruser",
Password: "mypass",
Roles: []mgo.Role{mgo.RoleRead},
OtherDBRoles: map[string][]mgo.Role{"mydb": []mgo.Role{mgo.RoleRead}},
}
err = admindb.UpsertUser(user)
Expand All @@ -254,7 +254,7 @@ func (s *S) TestAuthUpserUserUnsetFields(c *C) {

// Now update the user with few things set.
user = &mgo.User{
Username: "myruser",
Username: "myruser",
UserSource: "mydb",
}
err = admindb.UpsertUser(user)
Expand Down
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (cluster *mongoCluster) syncServer(server *mongoServer) (isMaster bool, hos
var tryerr error
for retry := 0; ; retry++ {
// Retry a few times as there is a small chance that a pre-existing
// socket times out exactly when an attempt is made to use it.
// socket times out exactly when an attempt is made to use it.
switch retry {
case 1, 2:
// Don't abuse the server needlessly if there's something actually wrong.
Expand Down
26 changes: 14 additions & 12 deletions cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -29,9 +29,9 @@ package mgo_test
import (
"fmt"
"io"
. "launchpad.net/gocheck"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
. "launchpad.net/gocheck"
"net"
"strings"
"time"
Expand Down Expand Up @@ -766,7 +766,7 @@ func (s *S) TestTopologySyncWithSlaveSeed(c *C) {
c.Assert(result.Ok, Equals, true)

// One connection to each during discovery. Master
// socket recycled for insert.
// socket recycled for insert.
stats := mgo.GetStats()
c.Assert(stats.MasterConns, Equals, 1)
c.Assert(stats.SlaveConns, Equals, 2)
Expand Down Expand Up @@ -1002,7 +1002,10 @@ func (s *S) TestRemovalOfClusterMember(c *C) {
c.Fatalf("Test started with bad cluster state: %v", master.LiveServers())
}

result := &struct{ IsMaster bool; Me string }{}
result := &struct {
IsMaster bool
Me string
}{}
slave := master.Copy()
slave.SetMode(mgo.Monotonic, true) // Monotonic can hold a non-master socket persistently.
err = slave.Run("isMaster", result)
Expand Down Expand Up @@ -1149,7 +1152,7 @@ func (s *S) TestCustomDial(c *C) {
}
info := mgo.DialInfo{
Addrs: []string{"localhost:40012"},
Dial: dial,
Dial: dial,
}

// Use hostname here rather than IP, to make things trickier.
Expand Down Expand Up @@ -1288,4 +1291,3 @@ func (s *S) TestNearestSecondary(c *C) {
c.Assert(hostPort(result.Host), Equals, hostPort(rs1b))
}
}

28 changes: 14 additions & 14 deletions gridfs.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -72,10 +72,10 @@ type GridFile struct {
}

type gfsFile struct {
Id interface{} "_id"
ChunkSize int "chunkSize"
UploadDate time.Time "uploadDate"
Length int64 ",minsize"
Id interface{} "_id"
ChunkSize int "chunkSize"
UploadDate time.Time "uploadDate"
Length int64 ",minsize"
MD5 string
Filename string ",omitempty"
ContentType string "contentType,omitempty"
Expand Down Expand Up @@ -165,7 +165,7 @@ func (gfs *GridFS) Create(name string) (file *GridFile, err error) {
// completed successfully.
//
// The following example will print the first 8192 bytes from the file:
//
//
// func check(err os.Error) {
// if err != nil {
// panic(err.String())
Expand Down Expand Up @@ -214,7 +214,7 @@ func (gfs *GridFS) OpenId(id interface{}) (file *GridFile, err error) {
// completed successfully.
//
// The following example will print the first 8192 bytes from the file:
//
//
// file, err := db.GridFS("fs").Open("myfile.txt")
// check(err)
// b := make([]byte, 8192)
Expand Down Expand Up @@ -307,7 +307,7 @@ func (gfs *GridFS) OpenNext(iter *Iter, file **GridFile) bool {
//
// files := db.C("fs" + ".files")
// iter := files.Find(nil).Iter()
//
//
func (gfs *GridFS) Find(query interface{}) *Query {
return gfs.Files.Find(query)
}
Expand Down
18 changes: 9 additions & 9 deletions gridfs_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -28,9 +28,9 @@ package mgo_test

import (
"io"
. "launchpad.net/gocheck"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
. "launchpad.net/gocheck"
"os"
"time"
)
Expand Down Expand Up @@ -161,7 +161,7 @@ func (s *S) TestGridFSFileDetails(c *C) {
ud := file.UploadDate()
now := time.Now()
c.Assert(ud.Before(now), Equals, true)
c.Assert(ud.After(now.Add(-3 * time.Second)), Equals, true)
c.Assert(ud.After(now.Add(-3*time.Second)), Equals, true)

result := M{}
err = db.C("fs.files").Find(nil).One(result)
Expand Down
14 changes: 7 additions & 7 deletions log.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down
14 changes: 7 additions & 7 deletions queue.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// mgo - MongoDB driver for Go
//
//
// Copyright (c) 2010-2012 - Gustavo Niemeyer <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down
Loading

0 comments on commit 406b882

Please sign in to comment.