Skip to content

Commit

Permalink
[FABG-840] Allow Go 1.12
Browse files Browse the repository at this point in the history
This change enables Go 1.12 support for tests and fixes errors
associated with 1.12.

Change-Id: Iba73f3ce887d0e77b9c452a5f4aa5d6f15f6ade2
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Apr 1, 2019
1 parent a7a340b commit f44a461
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ci.properties
Expand Up @@ -6,4 +6,4 @@

GO_VER=1.11.1
GO_MIN_VER=1.11
GO_MAX_VER=1.11.6
GO_MAX_VER=1.12.1
4 changes: 2 additions & 2 deletions pkg/client/resmgmt/resmgmt_test.go
Expand Up @@ -400,7 +400,7 @@ func TestIsChaincodeInstalled(t *testing.T) {
t.Fatal(err)
}
if !installed {
t.Fatalf("CC should have been installed: %s", req)
t.Fatalf("CC should have been installed: %+v", req)
}

// Chaincode not found request
Expand All @@ -412,7 +412,7 @@ func TestIsChaincodeInstalled(t *testing.T) {
t.Fatal(err)
}
if installed {
t.Fatalf("CC should NOT have been installed: %s", req)
t.Fatalf("CC should NOT have been installed: %+v", req)
}

// Test error retrieving installed cc info (peer is nil)
Expand Down
13 changes: 7 additions & 6 deletions pkg/core/logging/modlog/modlog.go
Expand Up @@ -433,7 +433,7 @@ func (l *Log) getCallerInfo(opts *loggerOpts) string {
}

const MAXCALLERS = 6 // search MAXCALLERS frames for the real caller
const SKIPCALLERS = 4 // skip SKIPCALLERS frames when determining the real caller
const SKIPCALLERS = 3 // skip SKIPCALLERS frames when determining the real caller
const NOTFOUND = "n/a"

fpcs := make([]uintptr, MAXCALLERS)
Expand All @@ -444,7 +444,7 @@ func (l *Log) getCallerInfo(opts *loggerOpts) string {
}

frames := runtime.CallersFrames(fpcs[:n])
funcIsNext := false
loggerFrameFound := false
for f, more := frames.Next(); more; f, more = frames.Next() {
pkgPath, fnName := filepath.Split(f.Function)

Expand All @@ -453,9 +453,9 @@ func (l *Log) getCallerInfo(opts *loggerOpts) string {
}

if hasLoggerFnPrefix(pkgPath, fnName) {
funcIsNext = true
loggerFrameFound = true

} else if funcIsNext {
} else if loggerFrameFound {
return fmt.Sprintf(callerInfoFormatter, fnName)
}
}
Expand All @@ -466,7 +466,8 @@ func (l *Log) getCallerInfo(opts *loggerOpts) string {
func hasLoggerFnPrefix(pkgPath string, fnName string) bool {
const (
loggingAPIPath = "github.com/hyperledger/fabric-sdk-go/pkg/core/logging/"
loggingAPIPkg = "api"
loggingAPIPkg = "api" // Go < 1.12
modlogFnPrefix = "modlog.(*Log)."
loggingPath = "github.com/hyperledger/fabric-sdk-go/pkg/common/"
loggingPkg = "logging"
logBridgePath = "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"
Expand All @@ -475,7 +476,7 @@ func hasLoggerFnPrefix(pkgPath string, fnName string) bool {

switch pkgPath {
case loggingAPIPath:
return strings.HasPrefix(fnName, loggingAPIPkg)
return strings.HasPrefix(fnName, modlogFnPrefix) || strings.HasPrefix(fnName, loggingAPIPkg)
case loggingPath:
return strings.HasPrefix(fnName, loggingPkg)
case logBridgePath:
Expand Down

0 comments on commit f44a461

Please sign in to comment.