Add Go 1.4 compatibility layer for raw64
Using raw64 will not work, but at least it will compile.
This commit is contained in:
parent
f4c367381e
commit
d15122d3d6
@ -25,7 +25,7 @@ type NameTransform struct {
|
|||||||
func New(c *cryptocore.CryptoCore, longNames bool, raw64 bool) *NameTransform {
|
func New(c *cryptocore.CryptoCore, longNames bool, raw64 bool) *NameTransform {
|
||||||
b64 := base64.URLEncoding
|
b64 := base64.URLEncoding
|
||||||
if raw64 {
|
if raw64 {
|
||||||
b64 = base64.RawURLEncoding
|
b64 = getRaw64Encoding()
|
||||||
}
|
}
|
||||||
return &NameTransform{
|
return &NameTransform{
|
||||||
cryptoCore: c,
|
cryptoCore: c,
|
||||||
|
18
internal/nametransform/raw64_go1.4.go
Normal file
18
internal/nametransform/raw64_go1.4.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//+build !go1.5
|
||||||
|
|
||||||
|
package nametransform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HaveRaw64 = false
|
||||||
|
)
|
||||||
|
|
||||||
|
func getRaw64Encoding() *base64.Encoding {
|
||||||
|
log.Panicf("Tried to use base64.RawURLEncoding but your Go version does not provide it.\n" +
|
||||||
|
"You need Go 1.5 or higher.")
|
||||||
|
return nil
|
||||||
|
}
|
15
internal/nametransform/raw64_go1.5.go
Normal file
15
internal/nametransform/raw64_go1.5.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//+build go1.5
|
||||||
|
|
||||||
|
package nametransform
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HaveRaw64 = true
|
||||||
|
)
|
||||||
|
|
||||||
|
func getRaw64Encoding() *base64.Encoding {
|
||||||
|
return base64.RawURLEncoding
|
||||||
|
}
|
@ -24,6 +24,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||||
|
"github.com/rfjakob/gocryptfs/internal/nametransform"
|
||||||
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
||||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||||
)
|
)
|
||||||
@ -63,6 +64,10 @@ func TestMain(m *testing.M) {
|
|||||||
fmt.Printf("Skipping Go GCM variant, Go installation is too old")
|
fmt.Printf("Skipping Go GCM variant, Go installation is too old")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if testcase.raw64 && !nametransform.HaveRaw64 {
|
||||||
|
fmt.Printf("Skipping raw64 test, Go installation is too old")
|
||||||
|
continue
|
||||||
|
}
|
||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
fmt.Printf("matrix: testcase = %#v\n", testcase)
|
fmt.Printf("matrix: testcase = %#v\n", testcase)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user