Skip to content

Commit

Permalink
Add lint Makefile target
Browse files Browse the repository at this point in the history
  • Loading branch information
lylex committed Dec 13, 2018
1 parent b24d52a commit 2e5d849
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
GO_BIN ?= go
GOFMT ?= gofmt
GOIMPORTS ?= goimports
GOLINT ?= golint
SOURCE_FILES ?= ./...

export GO111MODULE := on
Expand All @@ -15,6 +16,10 @@ test:
cover: test
$(GO_BIN) tool cover -html=coverage.out

.PHONY: lint
lint:
$(GOLINT) ./...

.PHONY: fmt
fmt:
find . -name '*.go' -not -wholename './vendor/*' | \
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
// TempFileStorePath TODO replate it
TempFileStorePath = "/Users/xuq3/workspace/drm/tem"

// CfgBlobPathKey represents the blobPath key in config.
CfgBlobPathKey = "blobPath"
)

Expand Down
14 changes: 11 additions & 3 deletions pkg/blobs/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@ import (
)

const (
// MaxRandomNumber represents the random number range [0, MaxRandomNumber).
MaxRandomNumber int = 10000

// MetaDataDB represents the name of the file used for storing metadata.
MetaDataDB string = "data.db"

// CfgDataPathKey represents the dataPath key in config.
CfgDataPathKey = "dataPath"
)

// Blob represents the blob instance.
type Blob struct {
// FileName represents the file name of the deleted file.
FileName string
Dir string

// Dir represent where the blob stored before deleted.
Dir string

// CreatedAt represents when the blob is created, i.e. when it is deleted.
CreatedAt time.Time
}

// Create make a blob metadate.
// Create makes a blob metadate.
func Create(fullPath string) *Blob {
return &Blob{
FileName: files.Name(fullPath),
Expand All @@ -36,14 +43,15 @@ func Create(fullPath string) *Blob {
}
}

// Name gets the name of the blob.
func (b *Blob) Name() string {
return fmt.Sprintf("%d_%4d_%s",
b.CreatedAt.UnixNano(),
rand.Intn(MaxRandomNumber),
b.FileName)
}

// TODO
// Save stores the blob metadata to disk.
func (b *Blob) Save() error {
db, err := buntdb.Open(viper.GetString(CfgDataPathKey) + MetaDataDB)
if err != nil {
Expand Down

0 comments on commit 2e5d849

Please sign in to comment.