From 6a6277464fba045b411d894aa2f874169391ff5f Mon Sep 17 00:00:00 2001 From: Aleksandr Tihomirov Date: Sat, 7 Jan 2017 11:43:19 +0200 Subject: [PATCH] chore(golint): Cleaning up code and adding docs --- cmd/gowo/cmd/upload.go | 4 ++-- cmd/gowo/cmd/watch.go | 2 +- endpoints.go | 1 + response.go | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/gowo/cmd/upload.go b/cmd/gowo/cmd/upload.go index 2f4c295..530a2f8 100644 --- a/cmd/gowo/cmd/upload.go +++ b/cmd/gowo/cmd/upload.go @@ -36,7 +36,7 @@ import ( "github.com/whats-this/owo.go" ) -func DoUpload(cdn string, names []string) { +func doUpload(cdn string, names []string) { files, err := owo.FilesToNamedReaders(names) if err != nil { log.Println("[upload]", err) @@ -82,7 +82,7 @@ var uploadCmd = &cobra.Command{ log.Fatal("Need at least one file.") } cdn := viper.GetString("cdn") - DoUpload(cdn, args) + doUpload(cdn, args) }, } diff --git a/cmd/gowo/cmd/watch.go b/cmd/gowo/cmd/watch.go index 9e0d1de..3d5b90e 100644 --- a/cmd/gowo/cmd/watch.go +++ b/cmd/gowo/cmd/watch.go @@ -76,7 +76,7 @@ var watchCmd = &cobra.Command{ continue } - go func() { DoUpload(cdn, names) }() + go doUpload(cdn, names) } }() diff --git a/endpoints.go b/endpoints.go index d6b6dd5..b7041b2 100644 --- a/endpoints.go +++ b/endpoints.go @@ -24,6 +24,7 @@ package owo // APIRoot defines base url for the service's API endpoints const APIRoot = "https://api.awau.moe" +// FileUploadLimit defines a set limit for pre-flight check before uploading files const FileUploadLimit = 83886080 var ( diff --git a/response.go b/response.go index 32fe7b9..b59e054 100644 --- a/response.go +++ b/response.go @@ -22,6 +22,7 @@ package owo type ( + // Response contains json marshalled response from owo Response struct { Success bool `json:"success"` Errorcode int `json:"errorcode"` @@ -29,6 +30,7 @@ type ( Files []File `json:"files"` } + // File represents a single file from json response (if there were no errors) File struct { Hash string `json:"hash,omitempty"` Name string `json:"name,omitempty"` @@ -40,6 +42,7 @@ type ( } ) +// WithCDN returns file url prefixed with the CDN func (f File) WithCDN(cdn string) string { return cdn + f.URL }