From 6b6391c250a72f43b50f3de739067680ac86b7d0 Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@nexedi.com>
Date: Wed, 4 Jul 2018 19:21:34 +0300
Subject: [PATCH] .

---
 go/neo/proto/proto-misc.go       | 21 ++++++++++++---------
 go/neo/proto/proto.go            |  2 +-
 go/neo/proto/proto_test.go       |  2 +-
 go/neo/proto/proto_vs_py_test.go |  2 +-
 go/neo/proto/protogen.go         |  2 --
 go/neo/proto/zproto-str.go       | 12 ++++++------
 6 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/go/neo/proto/proto-misc.go b/go/neo/proto/proto-misc.go
index 7ef80a96..6d1b3115 100644
--- a/go/neo/proto/proto-misc.go
+++ b/go/neo/proto/proto-misc.go
@@ -1,5 +1,5 @@
-// Copyright (C) 2017  Nexedi SA and Contributors.
-//                     Kirill Smelkov <kirr@nexedi.com>
+// Copyright (C) 2017-2018  Nexedi SA and Contributors.
+//                          Kirill Smelkov <kirr@nexedi.com>
 //
 // This program is free software: you can Use, Study, Modify and Redistribute
 // it under the terms of the GNU General Public License version 3, or (at your
@@ -40,9 +40,9 @@ func MsgType(msgCode uint16) reflect.Type {
 }
 
 
-// XXX or better translate to some other errors ?
-// XXX here - not in proto.go - because else stringer will be confused
 func (e *Error) Error() string {
+	// NOTE here, not in proto.go - because else stringer will be confused.
+	// XXX better translate to some other errors?
 	s := e.Code.String()
 	if e.Message != "" {
 		s += ": " + e.Message
@@ -52,6 +52,7 @@ func (e *Error) Error() string {
 
 
 // Set sets cluster state value to v.
+//
 // Use Set instead of direct assignment for ClusterState tracing to work.
 //
 // XXX move this to neo.clusterState wrapping proto.ClusterState?
@@ -60,10 +61,11 @@ func (cs *ClusterState) Set(v ClusterState) {
 	traceClusterStateChanged(cs)
 }
 
-//const nodeTypeChar = "MSCA????"	// keep in sync with NodeType constants
-const nodeTypeChar = "SMCA"	// XXX neo/py does this out of sync with NodeType constants
+// node type -> character representing it.
+const nodeTypeChar = "SMCA" // NOTE neo/py does this out of sync with NodeType constants.
 
 // String returns string representation of a node uuid.
+//
 // It returns ex 'S1', 'M2', ...
 func (nodeUUID NodeUUID) String() string {
 	if nodeUUID == 0 {
@@ -133,6 +135,7 @@ func UUID(typ NodeType, num int32) NodeUUID {
 
 // ----------------------------------------
 
+// IdTimeNone represents None passed as identification time.
 var IdTimeNone = IdTime(math.Inf(-1))
 
 func (t IdTime) String() string {
@@ -147,7 +150,7 @@ func (t IdTime) String() string {
 
 // ----------------------------------------
 
-// Addr converts network address string into NEO Address
+// AddrString converts network address string into NEO Address.
 //
 // TODO make neo.Address just string without host:port split
 func AddrString(network, addr string) (Address, error) {
@@ -181,12 +184,12 @@ func AddrString(network, addr string) (Address, error) {
 	return Address{Host: host, Port: uint16(port)}, nil
 }
 
-// Addr converts net.Addr into NEO Address
+// Addr converts net.Addr into NEO Address.
 func Addr(addr net.Addr) (Address, error) {
 	return AddrString(addr.Network(), addr.String())
 }
 
-// String formats Address to networked address string
+// String formats Address to networked address string.
 func (addr Address) String() string {
 	// XXX in py if .Host == "" -> whole Address is assumed to be empty
 
diff --git a/go/neo/proto/proto.go b/go/neo/proto/proto.go
index 5620e723..39c98c75 100644
--- a/go/neo/proto/proto.go
+++ b/go/neo/proto/proto.go
@@ -191,7 +191,7 @@ const (
 
 type NodeType int32
 const (
-	MASTER NodeType = iota
+	MASTER  NodeType = iota
 	STORAGE
 	CLIENT
 	ADMIN
diff --git a/go/neo/proto/proto_test.go b/go/neo/proto/proto_test.go
index 6578c16c..616fe529 100644
--- a/go/neo/proto/proto_test.go
+++ b/go/neo/proto/proto_test.go
@@ -275,7 +275,7 @@ func TestMsgMarshal(t *testing.T) {
 	}
 }
 
-// For all message types: same as testMsgMarshal but zero-values only
+// For all message types: same as testMsgMarshal but zero-values only.
 // this way we additionally lightly check encode / decode overflow behaviour for all types.
 func TestMsgMarshalAllOverflowLightly(t *testing.T) {
 	for _, typ := range msgTypeRegistry {
diff --git a/go/neo/proto/proto_vs_py_test.go b/go/neo/proto/proto_vs_py_test.go
index 6f093619..618d442a 100644
--- a/go/neo/proto/proto_vs_py_test.go
+++ b/go/neo/proto/proto_vs_py_test.go
@@ -29,7 +29,7 @@ import (
 	"github.com/kylelemons/godebug/pretty"
 )
 
-// verify that message codes are the same in between py and go
+// verify that message codes are the same in between py and go.
 func TestMsgCodeVsPy(t *testing.T) {
 	goMsgRegistry := map[uint16]string{} // code -> packet name
 	for code, pktType := range msgTypeRegistry{
diff --git a/go/neo/proto/protogen.go b/go/neo/proto/protogen.go
index c10e1ba6..8a84a56e 100644
--- a/go/neo/proto/protogen.go
+++ b/go/neo/proto/protogen.go
@@ -135,8 +135,6 @@ type localImporter struct {
 }
 
 func (li *localImporter) Import(path string) (*types.Package, error) {
-//	xpath := strings.TrimPrefix(path, "../") // ../zodb -> zodb
-//	pkg := pkgMap[xpath]
 	pkg := pkgMap[path]
 	if pkg != nil {
 		return pkg, nil
diff --git a/go/neo/proto/zproto-str.go b/go/neo/proto/zproto-str.go
index 4eaa3564..85f6f4d5 100644
--- a/go/neo/proto/zproto-str.go
+++ b/go/neo/proto/zproto-str.go
@@ -2,7 +2,7 @@
 
 package proto
 
-import "fmt"
+import "strconv"
 
 const _ErrorCode_name = "ACKNOT_READYOID_NOT_FOUNDTID_NOT_FOUNDOID_DOES_NOT_EXISTPROTOCOL_ERRORREPLICATION_ERRORCHECKING_ERRORBACKEND_NOT_IMPLEMENTEDNON_READABLE_CELLREAD_ONLY_ACCESSINCOMPLETE_TRANSACTION"
 
@@ -10,7 +10,7 @@ var _ErrorCode_index = [...]uint8{0, 3, 12, 25, 38, 56, 70, 87, 101, 124, 141, 1
 
 func (i ErrorCode) String() string {
 	if i >= ErrorCode(len(_ErrorCode_index)-1) {
-		return fmt.Sprintf("ErrorCode(%d)", i)
+		return "ErrorCode(" + strconv.FormatInt(int64(i), 10) + ")"
 	}
 	return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]]
 }
@@ -21,7 +21,7 @@ var _ClusterState_index = [...]uint8{0, 17, 33, 47, 62, 77, 86, 101}
 
 func (i ClusterState) String() string {
 	if i < 0 || i >= ClusterState(len(_ClusterState_index)-1) {
-		return fmt.Sprintf("ClusterState(%d)", i)
+		return "ClusterState(" + strconv.FormatInt(int64(i), 10) + ")"
 	}
 	return _ClusterState_name[_ClusterState_index[i]:_ClusterState_index[i+1]]
 }
@@ -32,7 +32,7 @@ var _NodeType_index = [...]uint8{0, 6, 13, 19, 24}
 
 func (i NodeType) String() string {
 	if i < 0 || i >= NodeType(len(_NodeType_index)-1) {
-		return fmt.Sprintf("NodeType(%d)", i)
+		return "NodeType(" + strconv.FormatInt(int64(i), 10) + ")"
 	}
 	return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]]
 }
@@ -43,7 +43,7 @@ var _NodeState_index = [...]uint8{0, 7, 11, 18, 25}
 
 func (i NodeState) String() string {
 	if i < 0 || i >= NodeState(len(_NodeState_index)-1) {
-		return fmt.Sprintf("NodeState(%d)", i)
+		return "NodeState(" + strconv.FormatInt(int64(i), 10) + ")"
 	}
 	return _NodeState_name[_NodeState_index[i]:_NodeState_index[i+1]]
 }
@@ -54,7 +54,7 @@ var _CellState_index = [...]uint8{0, 10, 21, 28, 37, 46}
 
 func (i CellState) String() string {
 	if i < 0 || i >= CellState(len(_CellState_index)-1) {
-		return fmt.Sprintf("CellState(%d)", i)
+		return "CellState(" + strconv.FormatInt(int64(i), 10) + ")"
 	}
 	return _CellState_name[_CellState_index[i]:_CellState_index[i+1]]
 }
-- 
2.30.9