From c49f7bbf916825ba97c520cf5cdc8926057a7bab Mon Sep 17 00:00:00 2001 From: Acconut Date: Mon, 23 Mar 2015 17:58:13 +0100 Subject: [PATCH] uppercase ID and URL to match golint --- datastore.go | 2 +- filestore/filestore.go | 2 +- handler.go | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/datastore.go b/datastore.go index ad62421..b7766d2 100644 --- a/datastore.go +++ b/datastore.go @@ -7,7 +7,7 @@ import ( type MetaData map[string]string type FileInfo struct { - Id string + ID string // Total file size in bytes specified in the NewUpload call Size int64 // Offset in bytes (zero-based) diff --git a/filestore/filestore.go b/filestore/filestore.go index a7efc3a..1873e9a 100644 --- a/filestore/filestore.go +++ b/filestore/filestore.go @@ -28,7 +28,7 @@ type FileStore struct { func (store FileStore) NewUpload(info tusd.FileInfo) (id string, err error) { id = uid.Uid() - info.Id = id + info.ID = id // Create .bin file with no content file, err := os.OpenFile(store.binPath(id), os.O_CREATE|os.O_WRONLY, defaultFilePerm) diff --git a/handler.go b/handler.go index 1ddc906..355aaf6 100644 --- a/handler.go +++ b/handler.go @@ -17,7 +17,7 @@ import ( var logger = log.New(os.Stdout, "[tusd] ", 0) -var reExtractFileId = regexp.MustCompile(`([^/]+)\/?$`) +var reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`) var ( ErrUnsupportedVersion = errors.New("unsupported version") @@ -80,7 +80,7 @@ func NewHandler(config Config) (*Handler, error) { return nil, err } - // Ensure base path ends with slash to remove logic from absFileUrl + // Ensure base path ends with slash to remove logic from absFileURL if base != "" && string(base[len(base)-1]) != "/" { base += "/" } @@ -218,7 +218,7 @@ func (handler *Handler) postFile(w http.ResponseWriter, r *http.Request) { } } - url := handler.absFileUrl(r, id) + url := handler.absFileURL(r, id) w.Header().Set("Location", url) w.WriteHeader(http.StatusCreated) } @@ -239,8 +239,8 @@ func (handler *Handler) headFile(w http.ResponseWriter, r *http.Request) { if info.IsFinal { v := "final;" - for _, uploadId := range info.PartialUploads { - v += " " + handler.absFileUrl(r, uploadId) + for _, uploadID := range info.PartialUploads { + v += " " + handler.absFileURL(r, uploadID) } w.Header().Set("Concat", v) } @@ -411,7 +411,7 @@ func (handler *Handler) sendError(w http.ResponseWriter, err error) { // Make an absolute URLs to the given upload id. If the base path is absolute // it will be prepended else the host and protocol from the request is used. -func (handler *Handler) absFileUrl(r *http.Request, id string) string { +func (handler *Handler) absFileURL(r *http.Request, id string) string { if handler.isBasePathAbs { return handler.basePath + id } @@ -453,8 +453,8 @@ func (handler *Handler) sizeOfUploads(ids []string) (size int64, err error) { func (handler *Handler) fillFinalUpload(id string, uploads []string) error { readers := make([]io.Reader, len(uploads)) - for index, uploadId := range uploads { - reader, err := handler.dataStore.GetReader(uploadId) + for index, uploadID := range uploads { + reader, err := handler.dataStore.GetReader(uploadID) if err != nil { return err } @@ -537,7 +537,7 @@ func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads [] } // Extract ids out of URL - result := reExtractFileId.FindStringSubmatch(value) + result := reExtractFileID.FindStringSubmatch(value) if len(result) != 2 { err = ErrInvalidConcat return