1+ //go:build include_gcs
2+ // +build include_gcs
3+
14// Package gcs provides a storagedriver.StorageDriver implementation to
25// store blobs in Google cloud storage.
36//
47// This package leverages the google.golang.org/cloud/storage client library
5- //for interfacing with gcs.
8+ // for interfacing with gcs.
69//
710// Because gcs is a key, value store the Stat call does not support last modification
811// time for directories (directories are an abstraction for key, value stores)
912//
1013// Note that the contents of incomplete uploads are not accessible even though
1114// Stat returns their length
12- //
13- //go:build include_gcs
14- // +build include_gcs
15-
1615package gcs
1716
1817import (
@@ -62,7 +61,6 @@ var rangeHeader = regexp.MustCompile(`^bytes=([0-9])+-([0-9]+)$`)
6261// driverParameters is a struct that encapsulates all of the driver parameters after all values have been set
6362type driverParameters struct {
6463 bucket string
65- config * jwt.Config
6664 email string
6765 privateKey []byte
6866 client * http.Client
@@ -88,6 +86,8 @@ func (factory *gcsDriverFactory) Create(parameters map[string]interface{}) (stor
8886 return FromParameters (parameters )
8987}
9088
89+ var _ storagedriver.StorageDriver = & driver {}
90+
9191// driver is a storagedriver.StorageDriver implementation backed by GCS
9292// Objects are stored at absolute keys in the provided bucket.
9393type driver struct {
@@ -298,7 +298,7 @@ func (d *driver) Reader(context context.Context, path string, offset int64) (io.
298298 if err != nil {
299299 return nil , err
300300 }
301- if offset == int64 ( obj .Size ) {
301+ if offset == obj .Size {
302302 return ioutil .NopCloser (bytes .NewReader ([]byte {})), nil
303303 }
304304 return nil , storagedriver.InvalidOffsetError {Path : path , Offset : offset }
@@ -434,7 +434,6 @@ func putContentsClose(wc *storage.Writer, contents []byte) error {
434434 }
435435 }
436436 if err != nil {
437- wc .CloseWithError (err )
438437 return err
439438 }
440439 return wc .Close ()
@@ -614,10 +613,10 @@ func (d *driver) Stat(context context.Context, path string) (storagedriver.FileI
614613 //try to get as folder
615614 dirpath := d .pathToDirKey (path )
616615
617- var query * storage.Query
618- query = & storage. Query {}
619- query . Prefix = dirpath
620- query . MaxResults = 1
616+ query := & storage.Query {
617+ Prefix : dirpath ,
618+ MaxResults : 1 ,
619+ }
621620
622621 objects , err := storageListObjects (gcsContext , d .bucket , query )
623622 if err != nil {
@@ -639,12 +638,12 @@ func (d *driver) Stat(context context.Context, path string) (storagedriver.FileI
639638}
640639
641640// List returns a list of the objects that are direct descendants of the
642- //given path.
641+ // given path.
643642func (d * driver ) List (context context.Context , path string ) ([]string , error ) {
644- var query * storage.Query
645- query = & storage. Query {}
646- query . Delimiter = "/"
647- query . Prefix = d . pathToDirKey ( path )
643+ query := & storage.Query {
644+ Delimiter : "/" ,
645+ Prefix : d . pathToDirKey ( path ),
646+ }
648647 list := make ([]string , 0 , 64 )
649648 for {
650649 objects , err := storageListObjects (d .context (context ), d .bucket , query )
0 commit comments