Run go fmt

This commit is contained in:
Jakob Unterwurzacher 2015-10-04 14:36:20 +02:00
parent 5bd08abf40
commit 89fef80d32
15 changed files with 120 additions and 121 deletions

View File

@ -1,8 +1,8 @@
package cryptfs package cryptfs
import ( import (
"io/ioutil"
"encoding/json" "encoding/json"
"io/ioutil"
) )
import "os" import "os"

View File

@ -1,8 +1,8 @@
package cryptfs package cryptfs
import ( import (
"testing"
"fmt" "fmt"
"testing"
) )
type testRange struct { type testRange struct {
@ -22,9 +22,9 @@ func TestSplitRange(t *testing.T) {
key := make([]byte, 16) key := make([]byte, 16)
f := NewCryptFS(key, true) f := NewCryptFS(key, true)
for _, r := range(ranges) { for _, r := range ranges {
parts := f.SplitRange(r.offset, r.length) parts := f.SplitRange(r.offset, r.length)
for _, p := range(parts) { for _, p := range parts {
if p.Length > DEFAULT_PLAINBS || p.Skip >= DEFAULT_PLAINBS { if p.Length > DEFAULT_PLAINBS || p.Skip >= DEFAULT_PLAINBS {
fmt.Printf("Test fail: n=%d, length=%d, offset=%d\n", p.BlockNo, p.Length, p.Skip) fmt.Printf("Test fail: n=%d, length=%d, offset=%d\n", p.BlockNo, p.Length, p.Skip)
t.Fail() t.Fail()
@ -45,7 +45,7 @@ func TestCiphertextRange(t *testing.T) {
key := make([]byte, 16) key := make([]byte, 16)
f := NewCryptFS(key, true) f := NewCryptFS(key, true)
for _, r := range(ranges) { for _, r := range ranges {
alignedOffset, alignedLength, skipBytes := f.CiphertextRange(r.offset, r.length) alignedOffset, alignedLength, skipBytes := f.CiphertextRange(r.offset, r.length)
if alignedLength < r.length { if alignedLength < r.length {
t.Fail() t.Fail()

View File

@ -3,9 +3,9 @@ package cryptfs
// CryptFS is the crypto backend of GoCryptFS // CryptFS is the crypto backend of GoCryptFS
import ( import (
"fmt"
"crypto/cipher"
"crypto/aes" "crypto/aes"
"crypto/cipher"
"fmt"
) )
const ( const (

View File

@ -4,11 +4,11 @@ package cryptfs
import ( import (
"bytes" "bytes"
"os"
"errors"
"crypto/cipher" "crypto/cipher"
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"errors"
"os"
) )
const ( const (

View File

@ -3,12 +3,12 @@ package cryptfs
// Filename encryption / decryption function // Filename encryption / decryption function
import ( import (
"crypto/cipher"
"crypto/aes" "crypto/aes"
"fmt" "crypto/cipher"
"strings"
"encoding/base64" "encoding/base64"
"errors" "errors"
"fmt"
"strings"
) )
const ( const (

View File

@ -1,8 +1,8 @@
package cryptfs package cryptfs
import ( import (
"testing"
"bytes" "bytes"
"testing"
) )
func TestTranslatePath(t *testing.T) { func TestTranslatePath(t *testing.T) {
@ -14,7 +14,7 @@ func TestTranslatePath(t *testing.T) {
key := make([]byte, 16) key := make([]byte, 16)
fs := NewCryptFS(key, true) fs := NewCryptFS(key, true)
for _, n := range(s) { for _, n := range s {
c := fs.EncryptPath(n) c := fs.EncryptPath(n)
d, err := fs.DecryptPath(c) d, err := fs.DecryptPath(c)
if err != nil { if err != nil {
@ -36,7 +36,7 @@ func TestPad16(t *testing.T) {
key := make([]byte, 16) key := make([]byte, 16)
fs := NewCryptFS(key, true) fs := NewCryptFS(key, true)
for i := range(s) { for i := range s {
orig := s[i] orig := s[i]
padded := fs.pad16(orig) padded := fs.pad16(orig)
if len(padded) <= len(orig) { if len(padded) <= len(orig) {

View File

@ -1,10 +1,10 @@
package cryptfs package cryptfs
import ( import (
"crypto/rand"
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"sync" "sync"
"crypto/rand"
) )
type nonce96 struct { type nonce96 struct {

10
main.go
View File

@ -1,18 +1,18 @@
package main package main
import ( import (
"runtime/pprof" "encoding/hex"
"io/ioutil"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"time"
"encoding/hex"
"runtime" "runtime"
"runtime/pprof"
"time"
"github.com/rfjakob/gocryptfs/pathfs_frontend"
"github.com/rfjakob/gocryptfs/cryptfs" "github.com/rfjakob/gocryptfs/cryptfs"
"github.com/rfjakob/gocryptfs/pathfs_frontend"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"

View File

@ -7,10 +7,10 @@ package benchmark
import ( import (
"bytes" "bytes"
"testing"
"github.com/spacemonkeygo/openssl"
"crypto/aes" "crypto/aes"
"crypto/cipher" "crypto/cipher"
"github.com/spacemonkeygo/openssl"
"testing"
) )
func BenchmarkAESGCMSeal4K(b *testing.B) { func BenchmarkAESGCMSeal4K(b *testing.B) {

View File

@ -1,9 +1,9 @@
package pathfs_frontend package pathfs_frontend
import ( import (
"io"
"bytes" "bytes"
"fmt" "fmt"
"io"
"os" "os"
"sync" "sync"
"syscall" "syscall"
@ -139,7 +139,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
status := fuse.OK status := fuse.OK
dataBuf := bytes.NewBuffer(data) dataBuf := bytes.NewBuffer(data)
blocks := f.cfs.SplitRange(uint64(off), uint64(len(data))) blocks := f.cfs.SplitRange(uint64(off), uint64(len(data)))
for _, b := range(blocks) { for _, b := range blocks {
blockData := dataBuf.Next(int(b.Length)) blockData := dataBuf.Next(int(b.Length))
@ -180,7 +180,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
// Write - FUSE call // Write - FUSE call
func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) { func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
cryptfs.Debug.Printf("ino%d: FUSE Write %s: offset=%d length=%d\n", f.ino, off, len(data)) cryptfs.Debug.Printf("ino%d: FUSE Write: offset=%d length=%d\n", f.ino, off, len(data))
fi, err := f.fd.Stat() fi, err := f.fd.Stat()
if err != nil { if err != nil {
@ -249,7 +249,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
// File grows // File grows
if newSize > oldSize { if newSize > oldSize {
blocks := f.cfs.SplitRange(oldSize, newSize-oldSize) blocks := f.cfs.SplitRange(oldSize, newSize-oldSize)
for _, b := range(blocks) { for _, b := range blocks {
// First and last block may be partial // First and last block may be partial
if b.IsPartial() { if b.IsPartial() {
off, _ := b.PlaintextRange() off, _ := b.PlaintextRange()

View File

@ -1,10 +1,10 @@
package pathfs_frontend package pathfs_frontend
import ( import (
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
"fmt"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
@ -24,7 +24,6 @@ func NewFS(key []byte, backing string, useOpenssl bool) *FS {
CryptFS: cryptfs.NewCryptFS(key, useOpenssl), CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
FileSystem: pathfs.NewLoopbackFileSystem(backing), FileSystem: pathfs.NewLoopbackFileSystem(backing),
backing: backing, backing: backing,
} }
} }
@ -52,7 +51,7 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat
func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
cryptfs.Debug.Printf("OpenDir(%s)\n", dirName) cryptfs.Debug.Printf("OpenDir(%s)\n", dirName)
cipherEntries, status := fs.FileSystem.OpenDir(fs.EncryptPath(dirName), context); cipherEntries, status := fs.FileSystem.OpenDir(fs.EncryptPath(dirName), context)
var plain []fuse.DirEntry var plain []fuse.DirEntry
if cipherEntries != nil { if cipherEntries != nil {
for i := range cipherEntries { for i := range cipherEntries {