From e8eb90a1377a3d67592f26db57e989bf746103d6 Mon Sep 17 00:00:00 2001 From: Zack Mullaly Date: Fri, 6 Apr 2018 10:49:13 -0400 Subject: [PATCH] Manually add the extra information to action expiration timestamps that get formatted into strings This makes the action signing code work with older and newer versions of the Go compiler. --- action.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/action.go b/action.go index ab0ad47c..df6346a8 100644 --- a/action.go +++ b/action.go @@ -332,8 +332,16 @@ func (a Action) String() (str string, err error) { if err != nil { return } - str += fmt.Sprintf("name=%s;target=%s;validfrom=%d;expireafter=%d;operations=%s;", - a.Name, a.Target, a.ValidFrom.UTC().Unix(), a.ExpireAfter.UTC().Unix(), args) + + // Before this addition, the code below (`str += fmt.Sprintf(...)`) was formatting + // `a.ExpireAfter.UTC().Unix()` as a string, using `%s`. In version 1.10 of the Go + // compiler, this is an error. However in older versions, the numeric value would + // be converted to a string and wrapped with the formatting information you see + // being added here. + expire := fmt.Sprintf("%%!s(int64=%d)", a.ExpireAfter.UTC().Unix()) + + str += fmt.Sprintf("name=%s;target=%s;validfrom=%d;expireafter=%s;operations=%s;", + a.Name, a.Target, a.ValidFrom.UTC().Unix(), expire, args) return }