aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Rasmussen2015-05-23 14:33:39 +0200
committerPetter Rasmussen2015-05-23 14:33:39 +0200
commitcfdc9858a0fc2758c6ffcdd7502d9a672df185fc (patch)
treeea0939012ecdf61320df22b953e3114d71b825d2
parent3696f1bbc323dd58174a15f8522a73258f6d7015 (diff)
downloadgdrive-cfdc9858a0fc2758c6ffcdd7502d9a672df185fc.tar.bz2
gofmt
-rw-r--r--util/drive.go98
-rw-r--r--util/generic.go12
2 files changed, 55 insertions, 55 deletions
diff --git a/util/drive.go b/util/drive.go
index 259912f..d9215ba 100644
--- a/util/drive.go
+++ b/util/drive.go
@@ -26,59 +26,59 @@ func ParentList(parents []*drive.ParentReference) string {
}
func InternalDownloadUrlAndExtension(info *drive.File, format string) (downloadUrl string, extension string, err error) {
- // Make a list of available mime types for this file
- availableMimeTypes := make([]string, 0)
- for mime, _ := range info.ExportLinks {
- availableMimeTypes = append(availableMimeTypes, mime)
- }
+ // Make a list of available mime types for this file
+ availableMimeTypes := make([]string, 0)
+ for mime, _ := range info.ExportLinks {
+ availableMimeTypes = append(availableMimeTypes, mime)
+ }
- mimeExtensions := map[string]string{
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
- "application/application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
- "application/vnd.oasis.opendocument.text": "odf",
- "application/x-vnd.oasis.opendocument.spreadsheet": "ods",
- "application/pdf": "pdf",
- "application/rtf": "rtf",
- "text/csv": "csv",
- "text/html": "html",
- "text/plain": "txt",
- "application/vnd.google-apps.script+json": "json",
- }
+ mimeExtensions := map[string]string{
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
+ "application/application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
+ "application/vnd.oasis.opendocument.text": "odf",
+ "application/x-vnd.oasis.opendocument.spreadsheet": "ods",
+ "application/pdf": "pdf",
+ "application/rtf": "rtf",
+ "text/csv": "csv",
+ "text/html": "html",
+ "text/plain": "txt",
+ "application/vnd.google-apps.script+json": "json",
+ }
- // Make a list of available formats for this file
- availableFormats := make([]string, 0)
- for _, mime := range availableMimeTypes {
- if ext, ok := mimeExtensions[mime]; ok {
- availableFormats = append(availableFormats, ext)
- }
- }
+ // Make a list of available formats for this file
+ availableFormats := make([]string, 0)
+ for _, mime := range availableMimeTypes {
+ if ext, ok := mimeExtensions[mime]; ok {
+ availableFormats = append(availableFormats, ext)
+ }
+ }
- // Return DownloadUrl if no format is specified
- if format == "" {
- if info.DownloadUrl == "" {
- return "", "", fmt.Errorf("A format needs to be specified to download this file (--format). Available formats: %s", strings.Join(availableFormats, ", "))
- }
- return info.DownloadUrl, "", nil
- }
+ // Return DownloadUrl if no format is specified
+ if format == "" {
+ if info.DownloadUrl == "" {
+ return "", "", fmt.Errorf("A format needs to be specified to download this file (--format). Available formats: %s", strings.Join(availableFormats, ", "))
+ }
+ return info.DownloadUrl, "", nil
+ }
- // Ensure that the specified format is available
- if !inArray(format, availableFormats) {
- if len(availableFormats) > 0 {
- return "", "", fmt.Errorf("Invalid format. Available formats: %s", strings.Join(availableFormats, ", "))
- } else {
- return "", "", fmt.Errorf("No export formats are available for this file")
- }
- }
+ // Ensure that the specified format is available
+ if !inArray(format, availableFormats) {
+ if len(availableFormats) > 0 {
+ return "", "", fmt.Errorf("Invalid format. Available formats: %s", strings.Join(availableFormats, ", "))
+ } else {
+ return "", "", fmt.Errorf("No export formats are available for this file")
+ }
+ }
- // Grab download url
- for mime, f := range mimeExtensions {
- if f == format {
- downloadUrl = info.ExportLinks[mime]
- break
- }
- }
+ // Grab download url
+ for mime, f := range mimeExtensions {
+ if f == format {
+ downloadUrl = info.ExportLinks[mime]
+ break
+ }
+ }
- extension = "." + format
- return
+ extension = "." + format
+ return
}
diff --git a/util/generic.go b/util/generic.go
index a4b92be..50c22f5 100644
--- a/util/generic.go
+++ b/util/generic.go
@@ -199,11 +199,11 @@ func columnPadder(items []map[string]string, key string, spacing int) func(strin
}
func inArray(needle string, haystack []string) bool {
- for _, x := range haystack {
- if needle == x {
- return true
- }
- }
+ for _, x := range haystack {
+ if needle == x {
+ return true
+ }
+ }
- return false
+ return false
}