diff --git a/clientv3/client_test.go b/clientv3/client_test.go index 2beac42e7..6d977a353 100644 --- a/clientv3/client_test.go +++ b/clientv3/client_test.go @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package clientv3 import ( diff --git a/clientv3/txn.go b/clientv3/txn.go index 12ca17075..84f224834 100644 --- a/clientv3/txn.go +++ b/clientv3/txn.go @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package clientv3 import ( diff --git a/pkg/types/urlsmap.go b/pkg/types/urlsmap.go index f7d5c1c90..17dc91f9d 100644 --- a/pkg/types/urlsmap.go +++ b/pkg/types/urlsmap.go @@ -20,6 +20,7 @@ import ( "strings" ) +// URLsMap is a map from a name to its URLs. type URLsMap map[string]URLs // NewURLsMap returns a URLsMap instantiated from the given string, @@ -41,7 +42,7 @@ func NewURLsMap(s string) (URLsMap, error) { // String returns NameURLPairs into discovery-formatted name-to-URLs sorted by name. func (c URLsMap) String() string { - pairs := make([]string, 0) + var pairs []string for name, urls := range c { for _, url := range urls { pairs = append(pairs, fmt.Sprintf("%s=%s", name, url.String())) @@ -54,7 +55,7 @@ func (c URLsMap) String() string { // URLs returns a list of all URLs. // The returned list is sorted in ascending lexicographical order. func (c URLsMap) URLs() []string { - urls := make([]string, 0) + var urls []string for _, us := range c { for _, u := range us { urls = append(urls, u.String()) @@ -64,6 +65,7 @@ func (c URLsMap) URLs() []string { return urls } +// Len returns the size of URLsMap. func (c URLsMap) Len() int { return len(c) } diff --git a/pkg/wait/wait_time.go b/pkg/wait/wait_time.go index 1ed277084..7911e404f 100644 --- a/pkg/wait/wait_time.go +++ b/pkg/wait/wait_time.go @@ -24,7 +24,7 @@ type WaitTime interface { // The chan will be triggered when Trigger is called with a // deadline that is later than the one it is waiting for. // The given deadline MUST be unique. The deadline should be - // retrived by calling time.Now() in most cases. + // retrieved by calling time.Now() in most cases. Wait(deadline time.Time) <-chan struct{} // Trigger triggers all the waiting chans with an earlier deadline. Trigger(deadline time.Time) diff --git a/raft/raft_test.go b/raft/raft_test.go index 672bf34b5..39f23f223 100644 --- a/raft/raft_test.go +++ b/raft/raft_test.go @@ -237,7 +237,7 @@ func TestProgressIsPaused(t *testing.T) { ins: newInflights(256), } if g := p.isPaused(); g != tt.w { - t.Errorf("#%d: shouldwait = %t, want %t", i, g, tt.w) + t.Errorf("#%d: paused= %t, want %t", i, g, tt.w) } } } @@ -1323,7 +1323,7 @@ func TestBcastBeat(t *testing.T) { } } -// tests the output of the statemachine when receiving MsgBeat +// tests the output of the state machine when receiving MsgBeat func TestRecvMsgBeat(t *testing.T) { tests := []struct { state StateType diff --git a/wal/wal.go b/wal/wal.go index 238724ab6..e42e07a70 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -60,7 +60,7 @@ var ( crcTable = crc32.MakeTable(crc32.Castagnoli) ) -// WAL is a logical repersentation of the stable storage. +// WAL is a logical representation of the stable storage. // WAL is either in read mode or append mode but not both. // A newly created WAL is in append mode, and ready for appending records. // A just opened WAL is in read mode, and ready for reading records. @@ -189,7 +189,7 @@ func openAtIndex(dirpath string, snap walpb.Snapshot, write bool) (*WAL, error) } if write { - // open the lastest wal file for appending + // open the last wal file for appending seq, _, err := parseWalName(names[len(names)-1]) if err != nil { rc.Close() @@ -315,7 +315,7 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb. // cut closes current file written and creates a new one ready to append. // cut first creates a temp wal file and writes necessary headers into it. -// Then cut atomtically rename temp wal file to a wal file. +// Then cut atomically rename temp wal file to a wal file. func (w *WAL) cut() error { // close old wal file if err := w.sync(); err != nil { @@ -428,7 +428,7 @@ func (w *WAL) ReleaseLockTo(index uint64) error { } // if no lock index is greater than the release index, we can - // release lock upto the last one(excluding). + // release lock up to the last one(excluding). if !found && len(w.locks) != 0 { smaller = len(w.locks) - 1 }