From 3aff05b32d8c654d9f643bde7792619cd5bec939 Mon Sep 17 00:00:00 2001 From: Tyler Bui-Palsulich Date: Thu, 25 Feb 2021 11:38:39 -0500 Subject: [PATCH] fix(internal/godocfx): use correct anchor links --- internal/godocfx/parse.go | 100 ++++- internal/godocfx/testdata/golden/index.yml | 499 ++++++++++++--------- 2 files changed, 360 insertions(+), 239 deletions(-) diff --git a/internal/godocfx/parse.go b/internal/godocfx/parse.go index d50add666d0..848aa959fa7 100644 --- a/internal/godocfx/parse.go +++ b/internal/godocfx/parse.go @@ -34,6 +34,7 @@ import ( "log" "os" "path/filepath" + "regexp" "sort" "strconv" "strings" @@ -155,7 +156,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result // Once the files are grouped by package, process each package // independently. for _, pi := range pkgInfos { - link := newLinker(pi.pkg.Imports, pi.importRenames) + link := newLinker(pi) topLevelDecls := pkgsite.TopLevelDecls(pi.doc) pkgItem := &item{ UID: pi.doc.ImportPath, @@ -183,7 +184,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result Type: "const", Summary: c.Doc, Langs: onlyGo, - Syntax: syntax{Content: pkgsite.PrintType(pi.fset, c.Decl, toURL, topLevelDecls)}, + Syntax: syntax{Content: pkgsite.PrintType(pi.fset, c.Decl, link.toURL, topLevelDecls)}, }) } for _, v := range pi.doc.Vars { @@ -199,7 +200,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result Type: "variable", Summary: v.Doc, Langs: onlyGo, - Syntax: syntax{Content: pkgsite.PrintType(pi.fset, v.Decl, toURL, topLevelDecls)}, + Syntax: syntax{Content: pkgsite.PrintType(pi.fset, v.Decl, link.toURL, topLevelDecls)}, }) } for _, t := range pi.doc.Types { @@ -213,7 +214,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result Type: "type", Summary: t.Doc, Langs: onlyGo, - Syntax: syntax{Content: pkgsite.PrintType(pi.fset, t.Decl, toURL, topLevelDecls)}, + Syntax: syntax{Content: pkgsite.PrintType(pi.fset, t.Decl, link.toURL, topLevelDecls)}, Examples: processExamples(t.Examples, pi.fset), } // Note: items are added as page.Children, rather than @@ -232,7 +233,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result Type: "const", Summary: c.Doc, Langs: onlyGo, - Syntax: syntax{Content: pkgsite.PrintType(pi.fset, c.Decl, toURL, topLevelDecls)}, + Syntax: syntax{Content: pkgsite.PrintType(pi.fset, c.Decl, link.toURL, topLevelDecls)}, }) } for _, v := range t.Vars { @@ -248,7 +249,7 @@ func parse(glob string, workingDir string, optionalExtraFiles []string) (*result Type: "variable", Summary: v.Doc, Langs: onlyGo, - Syntax: syntax{Content: pkgsite.PrintType(pi.fset, v.Decl, toURL, topLevelDecls)}, + Syntax: syntax{Content: pkgsite.PrintType(pi.fset, v.Decl, link.toURL, topLevelDecls)}, }) } @@ -313,18 +314,84 @@ type linker struct { // Behavior is undefined when a single import has different names in // different files. imports map[string]string + + // idToAnchor is a map from an ID to the anchor URL for that ID. + idToAnchor map[string]string } -func newLinker(rawImports map[string]*packages.Package, importSyntax map[string]string) *linker { +func newLinker(pi pkgInfo) *linker { imports := map[string]string{} - for path, pkg := range rawImports { + for path, pkg := range pi.pkg.Imports { name := pkg.Name - if rename := importSyntax[path]; rename != "" { + if rename := pi.importRenames[path]; rename != "" { name = rename } imports[name] = path } - return &linker{imports: imports} + + idToAnchor := buildIDToAnchor(pi) + + return &linker{imports: imports, idToAnchor: idToAnchor} +} + +// nonWordRegex is based on +// https://github.com/googleapis/doc-templates/blob/70eba5908e7b9aef5525d0f1f24194ae750f267e/third_party/docfx/templates/devsite/common.js#L27-L30. +var nonWordRegex = regexp.MustCompile("\\W") + +func buildIDToAnchor(pi pkgInfo) map[string]string { + idToAnchor := map[string]string{} + idToAnchor[pi.doc.ImportPath] = pi.doc.ImportPath + + for _, c := range pi.doc.Consts { + commaID := strings.Join(c.Names, ",") + uid := pi.doc.ImportPath + "." + commaID + for _, name := range c.Names { + idToAnchor[name] = uid + } + } + for _, v := range pi.doc.Vars { + commaID := strings.Join(v.Names, ",") + uid := pi.doc.ImportPath + "." + commaID + for _, name := range v.Names { + idToAnchor[name] = uid + } + } + for _, f := range pi.doc.Funcs { + uid := pi.doc.ImportPath + "." + f.Name + idToAnchor[f.Name] = uid + } + for _, t := range pi.doc.Types { + uid := pi.doc.ImportPath + "." + t.Name + idToAnchor[t.Name] = uid + for _, c := range t.Consts { + commaID := strings.Join(c.Names, ",") + uid := pi.doc.ImportPath + "." + commaID + for _, name := range c.Names { + idToAnchor[name] = uid + } + } + for _, v := range t.Vars { + commaID := strings.Join(v.Names, ",") + uid := pi.doc.ImportPath + "." + commaID + for _, name := range v.Names { + idToAnchor[name] = uid + } + } + for _, f := range t.Funcs { + uid := pi.doc.ImportPath + "." + t.Name + "." + f.Name + idToAnchor[f.Name] = uid + } + for _, m := range t.Methods { + uid := pi.doc.ImportPath + "." + t.Name + "." + m.Name + idToAnchor[m.Name] = uid + } + } + + for id, anchor := range idToAnchor { + idToAnchor[id] = nonWordRegex.ReplaceAllString(anchor, "_") + } + + return idToAnchor } func (l *linker) linkify(s string) string { @@ -342,11 +409,11 @@ func (l *linker) linkify(s string) string { // If s is not exported, it's probably a builtin. if !token.IsExported(s) { if doc.IsPredeclared(s) { - return href(toURL("builtin", s), s) + return href(l.toURL("builtin", s), s) } return fmt.Sprintf("%s%s", prefix, s) } - return fmt.Sprintf("%s%s", prefix, href(toURL("", s), s)) + return fmt.Sprintf("%s%s", prefix, href(l.toURL("", s), s)) } // Otherwise, it's in another package. split := strings.Split(s, ".") @@ -362,14 +429,17 @@ func (l *linker) linkify(s string) string { return fmt.Sprintf("%s%s", prefix, s) } name := split[1] - return fmt.Sprintf("%s%s.%s", prefix, href(toURL(pkgPath, ""), pkg), href(toURL(pkgPath, name), name)) + return fmt.Sprintf("%s%s.%s", prefix, href(l.toURL(pkgPath, ""), pkg), href(l.toURL(pkgPath, name), name)) } // TODO: link to the right baseURL, with the right module name and version // pattern. -func toURL(pkg, name string) string { +func (l *linker) toURL(pkg, name string) string { if pkg == "" { - return fmt.Sprintf("#%s", strings.ToLower(name)) + if anchor := l.idToAnchor[name]; anchor != "" { + name = anchor + } + return fmt.Sprintf("#%s", name) } baseURL := "https://pkg.go.dev" if name == "" { diff --git a/internal/godocfx/testdata/golden/index.yml b/internal/godocfx/testdata/golden/index.yml index cd10f67f251..045f4026600 100644 --- a/internal/godocfx/testdata/golden/index.yml +++ b/internal/godocfx/testdata/golden/index.yml @@ -329,8 +329,8 @@ items: langs: - go syntax: - content: "const (\n\tAllUsers ACLEntity - = \"allUsers\"\n\tAllAuthenticatedUsers ACLEntity + content: "const (\n\tAllUsers ACLEntity + = \"allUsers\"\n\tAllAuthenticatedUsers ACLEntity = \"allAuthenticatedUsers\"\n)" - uid: cloud.google.com/go/storage.ACLHandle name: ACLHandle @@ -354,9 +354,10 @@ items: langs: - go syntax: - content: func (a *ACLHandle) Delete(ctx context.Context, entity ACLEntity) - (err error) + content: func (a *ACLHandle) + Delete(ctx context.Context, + entity ACLEntity) (err + error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -374,9 +375,10 @@ items: langs: - go syntax: - content: func (a *ACLHandle) List(ctx context.Context) (rules []ACLRule, - err error) + content: func (a *ACLHandle) + List(ctx context.Context) + (rules []ACLRule, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -394,9 +396,10 @@ items: langs: - go syntax: - content: func (a *ACLHandle) Set(ctx context.Context, entity ACLEntity, - role ACLRole) (err error) + content: func (a *ACLHandle) + Set(ctx context.Context, + entity ACLEntity, role + ACLRole) (err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -423,8 +426,9 @@ items: langs: - go syntax: - content: "const (\n\tRoleOwner ACLRole = \"OWNER\"\n\tRoleReader - ACLRole = \"READER\"\n\tRoleWriter ACLRole + content: "const (\n\tRoleOwner ACLRole + = \"OWNER\"\n\tRoleReader ACLRole + = \"READER\"\n\tRoleWriter ACLRole = \"WRITER\"\n)" - uid: cloud.google.com/go/storage.ACLRule name: ACLRule @@ -437,11 +441,11 @@ items: langs: - go syntax: - content: "type ACLRule struct {\n\tEntity ACLEntity\n\tEntityID + content: "type ACLRule struct {\n\tEntity ACLEntity\n\tEntityID \ string\n\tRole ACLRole\n\tDomain string\n\tEmail - \ string\n\tProjectTeam - *ProjectTeam\n}" + href=\"#cloud_google_com_go_storage_ACLRole\">ACLRole\n\tDomain string\n\tEmail string\n\tProjectTeam + *ProjectTeam\n}" - uid: cloud.google.com/go/storage.BucketAttrs name: BucketAttrs id: BucketAttrs @@ -455,16 +459,16 @@ items: syntax: content: "type BucketAttrs struct {\n\t// Name is the name of the bucket.\n\t// This field is read-only.\n\tName string\n\n\t// - ACL is the list of access control rules on the bucket.\n\tACL []ACLRule\n\n\t// + ACL is the list of access control rules on the bucket.\n\tACL []ACLRule\n\n\t// BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of\n\t// UniformBucketLevelAccess is recommended above the use of this field.\n\t// Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled to\n\t// true, will enable UniformBucketLevelAccess.\n\tBucketPolicyOnly - BucketPolicyOnly\n\n\t// UniformBucketLevelAccess - configures access checks to use only bucket-level IAM\n\t// policies and ignore - any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// - for more information.\n\tUniformBucketLevelAccess UniformBucketLevelAccess\n\n\t// + BucketPolicyOnly\n\n\t// + UniformBucketLevelAccess configures access checks to use only bucket-level IAM\n\t// + policies and ignore any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// + for more information.\n\tUniformBucketLevelAccess UniformBucketLevelAccess\n\n\t// DefaultObjectACL is the list of access controls to\n\t// apply to new objects - when no object ACL is provided.\n\tDefaultObjectACL []ACLRule\n\n\t// + when no object ACL is provided.\n\tDefaultObjectACL []ACLRule\n\n\t// DefaultEventBasedHold is the default value for event-based hold on\n\t// newly created objects in this bucket. It defaults to false.\n\tDefaultEventBasedHold bool\n\n\t// If not empty, applies @@ -495,21 +499,22 @@ items: operations on Requester Pays buckets must provide\n\t// a user project (see BucketHandle.UserProject), which will be billed\n\t// for the operations.\n\tRequesterPays bool\n\n\t// Lifecycle is the - lifecycle configuration for objects in the bucket.\n\tLifecycle Lifecycle\n\n\t// + lifecycle configuration for objects in the bucket.\n\tLifecycle Lifecycle\n\n\t// Retention policy enforces a minimum retention time for all objects\n\t// contained in the bucket. A RetentionPolicy of nil implies the bucket\n\t// has no minimum data retention.\n\t//\n\t// This feature is in private alpha release. It is not currently available to\n\t// most customers. It might be changed in backwards-incompatible ways and is not\n\t// subject to any SLA or deprecation policy.\n\tRetentionPolicy - *RetentionPolicy\n\n\t// The bucket's Cross-Origin - Resource Sharing (CORS) configuration.\n\tCORS []CORS\n\n\t// - The encryption configuration used by default for newly inserted objects.\n\tEncryption - *BucketEncryption\n\n\t// The logging configuration.\n\tLogging - *BucketLogging\n\n\t// The website configuration.\n\tWebsite - *BucketWebsite\n\n\t// Etag is the HTTP/1.1 Entity - tag for the bucket.\n\t// This field is read-only.\n\tEtag string\n\n\t// - LocationType describes how data is stored and replicated.\n\t// Typical values - are \"multi-region\", \"region\" and \"dual-region\".\n\t// This field is read-only.\n\tLocationType + *RetentionPolicy\n\n\t// + The bucket's Cross-Origin Resource Sharing (CORS) configuration.\n\tCORS []CORS\n\n\t// The encryption configuration + used by default for newly inserted objects.\n\tEncryption *BucketEncryption\n\n\t// + The logging configuration.\n\tLogging *BucketLogging\n\n\t// + The website configuration.\n\tWebsite *BucketWebsite\n\n\t// + Etag is the HTTP/1.1 Entity tag for the bucket.\n\t// This field is read-only.\n\tEtag + string\n\n\t// LocationType + describes how data is stored and replicated.\n\t// Typical values are \"multi-region\", + \"region\" and \"dual-region\".\n\t// This field is read-only.\n\tLocationType string\n}" - uid: cloud.google.com/go/storage.BucketAttrsToUpdate name: BucketAttrsToUpdate @@ -535,24 +540,24 @@ items: OR UniformBucketLevelAccess.Enabled to\n\t// true, will enable UniformBucketLevelAccess. If both BucketPolicyOnly and\n\t// UniformBucketLevelAccess are set, the value of UniformBucketLevelAccess\n\t// will take precedence.\n\tBucketPolicyOnly - *BucketPolicyOnly\n\n\t// UniformBucketLevelAccess - configures access checks to use only bucket-level IAM\n\t// policies and ignore - any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// - for more information.\n\tUniformBucketLevelAccess *UniformBucketLevelAccess\n\n\t// + *BucketPolicyOnly\n\n\t// + UniformBucketLevelAccess configures access checks to use only bucket-level IAM\n\t// + policies and ignore any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// + for more information.\n\tUniformBucketLevelAccess *UniformBucketLevelAccess\n\n\t// If set, updates the retention policy of the bucket. Using\n\t// RetentionPolicy.RetentionPeriod = 0 will delete the existing policy.\n\t//\n\t// This feature is in private alpha release. It is not currently available to\n\t// most customers. It might be changed in backwards-incompatible ways and is not\n\t// subject to any SLA - or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// + or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// If set, replaces the CORS configuration with a new configuration.\n\t// An empty (rather than nil) slice causes all CORS policies to be removed.\n\tCORS []CORS\n\n\t// If set, replaces the encryption configuration - of the bucket. Using\n\t// BucketEncryption.DefaultKMSKeyName = \"\" will delete - the existing\n\t// configuration.\n\tEncryption *BucketEncryption\n\n\t// + href=\"#cloud_google_com_go_storage_CORS\">CORS\n\n\t// If set, replaces + the encryption configuration of the bucket. Using\n\t// BucketEncryption.DefaultKMSKeyName + = \"\" will delete the existing\n\t// configuration.\n\tEncryption *BucketEncryption\n\n\t// If set, replaces the lifecycle configuration of the bucket.\n\tLifecycle *Lifecycle\n\n\t// If set, replaces the logging configuration - of the bucket.\n\tLogging *BucketLogging\n\n\t// - If set, replaces the website configuration of the bucket.\n\tWebsite *BucketWebsite\n\n\t// + href=\"#cloud_google_com_go_storage_Lifecycle\">Lifecycle\n\n\t// If set, + replaces the logging configuration of the bucket.\n\tLogging *BucketLogging\n\n\t// + If set, replaces the website configuration of the bucket.\n\tWebsite *BucketWebsite\n\n\t// If not empty, applies a predefined set of access controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedACL string\n\n\t// If not empty, applies a predefined set of default object access controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedDefaultObjectACL @@ -570,8 +575,8 @@ items: langs: - go syntax: - content: func (ua *BucketAttrsToUpdate) DeleteLabel(name - string) + content: func (ua *BucketAttrsToUpdate) + DeleteLabel(name string) - uid: cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel name: | func (*BucketAttrsToUpdate) SetLabel @@ -584,8 +589,8 @@ items: langs: - go syntax: - content: func (ua *BucketAttrsToUpdate) SetLabel(name, - value string) + content: func (ua *BucketAttrsToUpdate) + SetLabel(name, value string) - uid: cloud.google.com/go/storage.BucketConditions name: BucketConditions id: BucketConditions @@ -653,7 +658,8 @@ items: langs: - go syntax: - content: func (b *BucketHandle) ACL() *ACLHandle + content: func (b *BucketHandle) + ACL() *ACLHandle - uid: cloud.google.com/go/storage.BucketHandle.AddNotification name: | func (*BucketHandle) AddNotification @@ -667,10 +673,11 @@ items: langs: - go syntax: - content: func (b *BucketHandle) AddNotification(ctx - context.Context, - n *Notification) (ret *Notification, - err error) + content: func (b *BucketHandle) + AddNotification(ctx context.Context, + n *Notification) (ret + *Notification, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -689,8 +696,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Attrs(ctx context.Context) (attrs *BucketAttrs, + content: func (b *BucketHandle) + Attrs(ctx context.Context) + (attrs *BucketAttrs, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc @@ -709,9 +717,10 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Create(ctx context.Context, projectID string, - attrs *BucketAttrs) (err error) + content: func (b *BucketHandle) + Create(ctx context.Context, + projectID string, attrs *BucketAttrs) (err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -730,8 +739,8 @@ items: langs: - go syntax: - content: func (b *BucketHandle) DefaultObjectACL() - *ACLHandle + content: func (b *BucketHandle) + DefaultObjectACL() *ACLHandle - uid: cloud.google.com/go/storage.BucketHandle.Delete name: | func (*BucketHandle) Delete @@ -743,8 +752,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Delete(ctx context.Context) (err error) + content: func (b *BucketHandle) + Delete(ctx context.Context) + (err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -761,8 +771,8 @@ items: langs: - go syntax: - content: func (b *BucketHandle) DeleteNotification(ctx - context.Context, + content: func (b *BucketHandle) + DeleteNotification(ctx context.Context, id string) (err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar @@ -782,8 +792,8 @@ items: langs: - go syntax: - content: func (b *BucketHandle) IAM() *iam.Handle + content: func (b *BucketHandle) + IAM() *iam.Handle - uid: cloud.google.com/go/storage.BucketHandle.If name: | func (*BucketHandle) If @@ -799,8 +809,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) If(conds BucketConditions) - *BucketHandle + content: func (b *BucketHandle) + If(conds BucketConditions) + *BucketHandle - uid: cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy name: | func (*BucketHandle) LockRetentionPolicy @@ -820,9 +831,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) LockRetentionPolicy(ctx - context.Context) - error + content: func (b *BucketHandle) + LockRetentionPolicy(ctx context.Context) error codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -844,9 +855,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Notifications(ctx - context.Context) - (n map[string]*Notification, + content: func (b *BucketHandle) + Notifications(ctx context.Context) + (n map[string]*Notification, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc @@ -870,8 +881,8 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Object(name string) - *ObjectHandle + content: func (b *BucketHandle) + Object(name string) *ObjectHandle - uid: cloud.google.com/go/storage.BucketHandle.Objects name: | func (*BucketHandle) Objects @@ -886,9 +897,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Objects(ctx context.Context, q *Query) - *ObjectIterator + content: func (b *BucketHandle) + Objects(ctx context.Context, + q *Query) *ObjectIterator codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -905,9 +916,11 @@ items: langs: - go syntax: - content: func (b *BucketHandle) Update(ctx context.Context, uattrs BucketAttrsToUpdate) - (attrs *BucketAttrs, err error) + content: func (b *BucketHandle) + Update(ctx context.Context, + uattrs BucketAttrsToUpdate) + (attrs *BucketAttrs, + err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -938,8 +951,9 @@ items: langs: - go syntax: - content: func (b *BucketHandle) UserProject(projectID - string) *BucketHandle + content: func (b *BucketHandle) + UserProject(projectID string) + *BucketHandle - uid: cloud.google.com/go/storage.BucketIterator name: BucketIterator id: BucketIterator @@ -970,7 +984,8 @@ items: langs: - go syntax: - content: func (it *BucketIterator) Next() (*BucketAttrs, + content: func (it *BucketIterator) + Next() (*BucketAttrs, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc @@ -991,8 +1006,9 @@ items: langs: - go syntax: - content: func (it *BucketIterator) PageInfo() *iterator.PageInfo + content: func (it *BucketIterator) + PageInfo() *iterator.PageInfo - uid: cloud.google.com/go/storage.BucketLogging name: BucketLogging id: BucketLogging @@ -1099,7 +1115,7 @@ items: content: func NewClient(ctx context.Context, opts ...option.ClientOption) - (*Client, error) + (*Client, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\t// Use Google Application Default @@ -1131,8 +1147,8 @@ items: langs: - go syntax: - content: func (c *Client) Bucket(name string) - *BucketHandle + content: func (c *Client) Bucket(name + string) *BucketHandle - uid: cloud.google.com/go/storage.Client.Buckets name: | func (*Client) Buckets @@ -1149,9 +1165,9 @@ items: langs: - go syntax: - content: func (c *Client) Buckets(ctx context.Context, projectID string) - *BucketIterator + content: func (c *Client) Buckets(ctx + context.Context, + projectID string) *BucketIterator codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1170,7 +1186,8 @@ items: langs: - go syntax: - content: func (c *Client) Close() error + content: func (c *Client) Close() + error - uid: cloud.google.com/go/storage.Client.CreateHMACKey name: | func (*Client) CreateHMACKey @@ -1184,10 +1201,11 @@ items: langs: - go syntax: - content: func (c *Client) CreateHMACKey(ctx context.Context, projectID, serviceAccountEmail - string, opts ...HMACKeyOption) - (*HMACKey, error) + content: func (c *Client) CreateHMACKey(ctx + context.Context, + projectID, serviceAccountEmail string, + opts ...HMACKeyOption) + (*HMACKey, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1207,8 +1225,8 @@ items: langs: - go syntax: - content: func (c *Client) HMACKeyHandle(projectID, accessID - string) *HMACKeyHandle + content: func (c *Client) HMACKeyHandle(projectID, + accessID string) *HMACKeyHandle - uid: cloud.google.com/go/storage.Client.ListHMACKeys name: | func (*Client) ListHMACKeys @@ -1224,9 +1242,10 @@ items: langs: - go syntax: - content: func (c *Client) ListHMACKeys(ctx context.Context, projectID string, - opts ...HMACKeyOption) *HMACKeysIterator + content: func (c *Client) ListHMACKeys(ctx + context.Context, + projectID string, opts ...HMACKeyOption) *HMACKeysIterator codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1260,9 +1279,10 @@ items: langs: - go syntax: - content: func (c *Client) ServiceAccount(ctx context.Context, projectID string) - (string, error) + content: func (c *Client) ServiceAccount(ctx + context.Context, + projectID string) (string, + error) - uid: cloud.google.com/go/storage.Composer name: Composer id: Composer @@ -1278,13 +1298,13 @@ items: content: "type Composer struct {\n\t// ObjectAttrs are optional attributes to set on the destination object.\n\t// Any attributes must be initialized before any calls on the Composer. Nil\n\t// or zero-valued attributes are ignored.\n\tObjectAttrs\n\n\t// SendCRC specifies whether to transmit - a CRC32C field. It should be set\n\t// to true in addition to setting the Composer's - CRC32C field, because zero\n\t// is a valid CRC and normally a zero would not - be transmitted.\n\t// If a CRC32C is sent, and the data in the destination object - does not match\n\t// the checksum, the compose will be rejected.\n\tSendCRC32C - bool\n\t// contains filtered - or unexported fields\n}" + href=\"#cloud_google_com_go_storage_ObjectAttrs\">ObjectAttrs\n\n\t// SendCRC + specifies whether to transmit a CRC32C field. It should be set\n\t// to true + in addition to setting the Composer's CRC32C field, because zero\n\t// is a + valid CRC and normally a zero would not be transmitted.\n\t// If a CRC32C is + sent, and the data in the destination object does not match\n\t// the checksum, + the compose will be rejected.\n\tSendCRC32C bool\n\t// + contains filtered or unexported fields\n}" - uid: cloud.google.com/go/storage.Composer.Run name: | func (*Composer) Run @@ -1296,8 +1316,9 @@ items: langs: - go syntax: - content: func (c *Composer) Run(ctx context.Context) (attrs *ObjectAttrs, + content: func (c *Composer) + Run(ctx context.Context) + (attrs *ObjectAttrs, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc @@ -1355,10 +1376,10 @@ items: content: "type Copier struct {\n\t// ObjectAttrs are optional attributes to set on the destination object.\n\t// Any attributes must be initialized before any calls on the Copier. Nil\n\t// or zero-valued attributes are ignored.\n\tObjectAttrs\n\n\t// RewriteToken can be set before - calling Run to resume a copy\n\t// operation. After Run returns a non-nil error, - RewriteToken will\n\t// have been updated to contain the value needed to resume - the copy.\n\tRewriteToken string\n\n\t// + href=\"#cloud_google_com_go_storage_ObjectAttrs\">ObjectAttrs\n\n\t// RewriteToken + can be set before calling Run to resume a copy\n\t// operation. After Run returns + a non-nil error, RewriteToken will\n\t// have been updated to contain the value + needed to resume the copy.\n\tRewriteToken string\n\n\t// ProgressFunc can be used to monitor the progress of a multi-RPC copy\n\t// operation. If ProgressFunc is not nil and copying requires multiple\n\t// calls to the underlying service (see\n\t// https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite), @@ -1386,8 +1407,9 @@ items: langs: - go syntax: - content: func (c *Copier) Run(ctx context.Context) (attrs *ObjectAttrs, + content: func (c *Copier) Run(ctx + context.Context) + (attrs *ObjectAttrs, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc @@ -1436,7 +1458,7 @@ items: modification time of the HMAC key metadata.\n\tUpdatedTime time.Time\n\n\t// State is the state of the HMAC key.\n\t// It can be one of StateActive, StateInactive or StateDeleted.\n\tState - HMACState\n}" + HMACState\n}" - uid: cloud.google.com/go/storage.HMACKeyAttrsToUpdate name: HMACKeyAttrsToUpdate id: HMACKeyAttrsToUpdate @@ -1450,7 +1472,7 @@ items: - go syntax: content: "type HMACKeyAttrsToUpdate struct {\n\t// State is required and must - be either StateActive or StateInactive.\n\tState HMACState\n\n\t// + be either StateActive or StateInactive.\n\tState HMACState\n\n\t// Etag is an optional field and it is the HTTP/1.1 Entity tag.\n\tEtag string\n}" - uid: cloud.google.com/go/storage.HMACKeyHandle name: HMACKeyHandle @@ -1480,9 +1502,10 @@ items: langs: - go syntax: - content: func (hkh *HMACKeyHandle) Delete(ctx context.Context, - opts ...HMACKeyOption) error + content: func (hkh *HMACKeyHandle) + Delete(ctx context.Context, + opts ...HMACKeyOption) + error codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1507,9 +1530,10 @@ items: langs: - go syntax: - content: func (hkh *HMACKeyHandle) Get(ctx context.Context, opts ...HMACKeyOption) - (*HMACKey, error) + content: func (hkh *HMACKeyHandle) + Get(ctx context.Context, + opts ...HMACKeyOption) + (*HMACKey, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1529,10 +1553,11 @@ items: langs: - go syntax: - content: func (h *HMACKeyHandle) Update(ctx context.Context, au HMACKeyAttrsToUpdate, - opts ...HMACKeyOption) (*HMACKey, - error) + content: func (h *HMACKeyHandle) + Update(ctx context.Context, + au HMACKeyAttrsToUpdate, + opts ...HMACKeyOption) + (*HMACKey, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -1572,7 +1597,7 @@ items: - go syntax: content: func ForHMACKeyServiceAccountEmail(serviceAccountEmail string) - HMACKeyOption + HMACKeyOption - uid: cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys name: | func ShowDeletedHMACKeys @@ -1586,7 +1611,7 @@ items: langs: - go syntax: - content: func ShowDeletedHMACKeys() HMACKeyOption + content: func ShowDeletedHMACKeys() HMACKeyOption - uid: cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys name: | func UserProjectForHMACKeys @@ -1604,7 +1629,7 @@ items: - go syntax: content: func UserProjectForHMACKeys(userProjectID string) - HMACKeyOption + HMACKeyOption - uid: cloud.google.com/go/storage.HMACKeysIterator name: HMACKeysIterator id: HMACKeysIterator @@ -1638,8 +1663,8 @@ items: langs: - go syntax: - content: func (it *HMACKeysIterator) Next() (*HMACKey, error) + content: func (it *HMACKeysIterator) + Next() (*HMACKey, error) - uid: cloud.google.com/go/storage.HMACKeysIterator.PageInfo name: | func (*HMACKeysIterator) PageInfo @@ -1655,8 +1680,8 @@ items: langs: - go syntax: - content: func (it *HMACKeysIterator) PageInfo() - *iterator.HMACKeysIterator) + PageInfo() *iterator.PageInfo - uid: cloud.google.com/go/storage.HMACState name: HMACState @@ -1680,13 +1705,13 @@ items: - go syntax: content: "const (\n\t// Active is the status for an active key that can be used - to sign\n\t// requests.\n\tActive HMACState = \"ACTIVE\"\n\n\t// - Inactive is the status for an inactive key thus requests signed by\n\t// this - key will be denied.\n\tInactive HMACState = \"INACTIVE\"\n\n\t// - Deleted is the status for a key that is deleted.\n\t// Once in this state the - key cannot key cannot be recovered\n\t// and does not count towards key limits. - Deleted keys will be cleaned\n\t// up later.\n\tDeleted HMACState - = \"DELETED\"\n)" + to sign\n\t// requests.\n\tActive HMACState + = \"ACTIVE\"\n\n\t// Inactive is the status for an inactive key thus requests + signed by\n\t// this key will be denied.\n\tInactive HMACState + = \"INACTIVE\"\n\n\t// Deleted is the status for a key that is deleted.\n\t// + Once in this state the key cannot key cannot be recovered\n\t// and does not + count towards key limits. Deleted keys will be cleaned\n\t// up later.\n\tDeleted + HMACState = \"DELETED\"\n)" - uid: cloud.google.com/go/storage.Lifecycle name: Lifecycle id: Lifecycle @@ -1697,7 +1722,7 @@ items: langs: - go syntax: - content: "type Lifecycle struct {\n\tRules []LifecycleRule\n}" + content: "type Lifecycle struct {\n\tRules []LifecycleRule\n}" - uid: cloud.google.com/go/storage.LifecycleAction name: LifecycleAction id: LifecycleAction @@ -1743,7 +1768,7 @@ items: is the days elapsed since the noncurrent timestamp\n\t// of the object. This condition is relevant only for versioned objects.\n\tDaysSinceNoncurrentTime int64\n\n\t// Liveness specifies - the object's liveness. Relevant only for versioned objects\n\tLiveness Liveness\n\n\t// + the object's liveness. Relevant only for versioned objects\n\tLiveness Liveness\n\n\t// MatchesStorageClasses is the condition matching the object's storage\n\t// class.\n\t//\n\t// Values include \"STANDARD\", \"NEARLINE\", \"COLDLINE\" and \"ARCHIVE\".\n\tMatchesStorageClasses []string\n\n\t// NoncurrentTimeBefore @@ -1769,9 +1794,9 @@ items: - go syntax: content: "type LifecycleRule struct {\n\t// Action is the action to take when - all of the associated conditions are\n\t// met.\n\tAction LifecycleAction\n\n\t// + all of the associated conditions are\n\t// met.\n\tAction LifecycleAction\n\n\t// Condition is the set of conditions that must be met for the associated\n\t// - action to be taken.\n\tCondition LifecycleCondition\n}" + action to be taken.\n\tCondition LifecycleCondition\n}" - uid: cloud.google.com/go/storage.Liveness name: Liveness id: Liveness @@ -1792,7 +1817,7 @@ items: - go syntax: content: "const (\n\t// LiveAndArchived includes both live and archived objects.\n\tLiveAndArchived - Liveness = iota\n\t// + Liveness = iota\n\t// Live specifies that the object is still live.\n\tLive\n\t// Archived specifies that the object is archived.\n\tArchived\n)" - uid: cloud.google.com/go/storage.Notification @@ -1849,7 +1874,7 @@ items: earliest time that the object's retention period expires.\n\t// This is a read-only field.\n\tRetentionExpirationTime time.Time\n\n\t// ACL is the list of access - control rules for the object.\n\tACL []ACLRule\n\n\t// + control rules for the object.\n\tACL []ACLRule\n\n\t// If not empty, applies a predefined set of access controls. It should be set\n\t// only when writing, copying or composing an object. When copying or composing,\n\t// it acts as the destinationPredefinedAcl parameter.\n\t// PredefinedACL is always @@ -1952,7 +1977,7 @@ items: href=\"https://pkg.go.dev/cloud.google.com/go/internal/optional#String\">String\n\tCustomTime \ time.Time\n\tMetadata \ map[string]string - // set to map[string]string{} to delete\n\tACL []ACLRule\n\n\t// + // set to map[string]string{} to delete\n\tACL []ACLRule\n\n\t// If not empty, applies a predefined set of access controls. ACL must be nil.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/objects/patch.\n\tPredefinedACL string\n}" @@ -1989,7 +2014,8 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) ACL() *ACLHandle + content: func (o *ObjectHandle) + ACL() *ACLHandle - uid: cloud.google.com/go/storage.ObjectHandle.Attrs name: | func (*ObjectHandle) Attrs @@ -2002,8 +2028,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) Attrs(ctx context.Context) (attrs *ObjectAttrs, + content: func (o *ObjectHandle) + Attrs(ctx context.Context) + (attrs *ObjectAttrs, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc @@ -2030,7 +2057,8 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) BucketName() string + content: func (o *ObjectHandle) + BucketName() string - uid: cloud.google.com/go/storage.ObjectHandle.ComposerFrom name: | func (*ObjectHandle) ComposerFrom @@ -2048,8 +2076,9 @@ items: langs: - go syntax: - content: func (dst *ObjectHandle) ComposerFrom(srcs - ...*ObjectHandle) *Composer + content: func (dst *ObjectHandle) + ComposerFrom(srcs ...*ObjectHandle) + *Composer - uid: cloud.google.com/go/storage.ObjectHandle.CopierFrom name: | func (*ObjectHandle) CopierFrom @@ -2066,8 +2095,9 @@ items: langs: - go syntax: - content: func (dst *ObjectHandle) CopierFrom(src *ObjectHandle) *Copier + content: func (dst *ObjectHandle) + CopierFrom(src *ObjectHandle) + *Copier codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar key1, key2 []byte\n\nfunc main() {\n\t// To rotate the encryption key on an @@ -2088,8 +2118,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) Delete(ctx context.Context) error + content: func (o *ObjectHandle) + Delete(ctx context.Context) + error codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -2118,8 +2149,8 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) Generation(gen int64) *ObjectHandle + content: func (o *ObjectHandle) + Generation(gen int64) *ObjectHandle codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"io\"\n\t\"os\"\n)\n\nvar gen int64\n\nfunc main() {\n\t// Read an object's contents from generation gen, @@ -2143,8 +2174,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) If(conds Conditions) - *ObjectHandle + content: func (o *ObjectHandle) + If(conds Conditions) *ObjectHandle codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n)\n\nvar gen int64\n\nfunc main() {\n\t// Read from an object only if the current generation @@ -2172,8 +2204,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) Key(encryptionKey - []byte) *ObjectHandle + content: func (o *ObjectHandle) + Key(encryptionKey []byte) *ObjectHandle codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar secretKey []byte\n\nfunc main() {\n\tctx := context.Background()\n\tclient, @@ -2202,10 +2235,10 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) NewRangeReader(ctx - context.Context, + content: func (o *ObjectHandle) + NewRangeReader(ctx context.Context, offset, length int64) (r *Reader, err error) + href="#cloud_google_com_go_storage_Reader">Reader, err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -2245,9 +2278,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) NewReader(ctx context.Context) (*Reader, - error) + content: func (o *ObjectHandle) + NewReader(ctx context.Context) + (*Reader, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -2280,8 +2313,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) NewWriter(ctx context.Context) *Writer + content: func (o *ObjectHandle) + NewWriter(ctx context.Context) + *Writer codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -2298,7 +2332,8 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) ObjectName() string + content: func (o *ObjectHandle) + ObjectName() string - uid: cloud.google.com/go/storage.ObjectHandle.ReadCompressed name: | func (*ObjectHandle) ReadCompressed @@ -2310,8 +2345,9 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) ReadCompressed(compressed - bool) *ObjectHandle + content: func (o *ObjectHandle) + ReadCompressed(compressed bool) + *ObjectHandle - uid: cloud.google.com/go/storage.ObjectHandle.Update name: | func (*ObjectHandle) Update @@ -2325,9 +2361,11 @@ items: langs: - go syntax: - content: func (o *ObjectHandle) Update(ctx context.Context, uattrs ObjectAttrsToUpdate) - (oa *ObjectAttrs, err error) + content: func (o *ObjectHandle) + Update(ctx context.Context, + uattrs ObjectAttrsToUpdate) + (oa *ObjectAttrs, err + error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -2368,7 +2406,8 @@ items: langs: - go syntax: - content: func (it *ObjectIterator) Next() (*ObjectAttrs, + content: func (it *ObjectIterator) + Next() (*ObjectAttrs, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc @@ -2389,8 +2428,9 @@ items: langs: - go syntax: - content: func (it *ObjectIterator) PageInfo() *iterator.PageInfo + content: func (it *ObjectIterator) + PageInfo() *iterator.PageInfo - uid: cloud.google.com/go/storage.PolicyV4Fields name: PolicyV4Fields id: PolicyV4Fields @@ -2448,8 +2488,8 @@ items: - go syntax: content: func GenerateSignedPostPolicyV4(bucket, object string, - opts *PostPolicyV4Options) (*PostPolicyV4, - error) + opts *PostPolicyV4Options) + (*PostPolicyV4, error) codeexamples: - content: "package main\n\nimport (\n\t\"bytes\"\n\t\"cloud.google.com/go/storage\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc main() {\n\tpv4, err := storage.GenerateSignedPostPolicyV4(\"my-bucket\", \"my-object.txt\", @@ -2501,7 +2541,7 @@ items: - go syntax: content: func ConditionContentLengthRange(start, end uint64) - PostPolicyV4Condition + PostPolicyV4Condition - uid: cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith name: | func ConditionStartsWith @@ -2515,7 +2555,7 @@ items: - go syntax: content: func ConditionStartsWith(key, value string) - PostPolicyV4Condition + PostPolicyV4Condition - uid: cloud.google.com/go/storage.PostPolicyV4Options name: PostPolicyV4Options id: PostPolicyV4Options @@ -2557,16 +2597,16 @@ items: href=\"https://pkg.go.dev/time#Time\">Time\n\n\t// Style provides options for the type of URL to use. Options are\n\t// PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See\n\t// https://cloud.google.com/storage/docs/request-endpoints - for details.\n\t// Optional.\n\tStyle URLStyle\n\n\t// + for details.\n\t// Optional.\n\tStyle URLStyle\n\n\t// Insecure when set indicates that the generated URL's scheme\n\t// will use \"http\" instead of \"https\" (default).\n\t// Optional.\n\tInsecure bool\n\n\t// Fields specifies the attributes of a PostPolicyV4 request.\n\t// When Fields is non-nil, its attributes must match those that will\n\t// passed into field - Conditions.\n\t// Optional.\n\tFields *PolicyV4Fields\n\n\t// + Conditions.\n\t// Optional.\n\tFields *PolicyV4Fields\n\n\t// The conditions that the uploaded file will be expected to conform to.\n\t// When used, the failure of an upload to satisfy a condition will result in\n\t// a 4XX status code, back with the message describing the problem.\n\t// Optional.\n\tConditions - []PostPolicyV4Condition\n}" + []PostPolicyV4Condition\n}" - uid: cloud.google.com/go/storage.ProjectTeam name: ProjectTeam id: ProjectTeam @@ -2624,8 +2664,8 @@ items: langs: - go syntax: - content: func (q *Query) SetAttrSelection(attrs []string) - error + content: func (q *Query) SetAttrSelection(attrs + []string) error - uid: cloud.google.com/go/storage.Reader name: Reader id: Reader @@ -2641,7 +2681,7 @@ items: langs: - go syntax: - content: "type Reader struct {\n\tAttrs ReaderObjectAttrs\n\t// + content: "type Reader struct {\n\tAttrs ReaderObjectAttrs\n\t// contains filtered or unexported fields\n}" - uid: cloud.google.com/go/storage.Reader.CacheControl name: | @@ -2656,7 +2696,8 @@ items: langs: - go syntax: - content: func (r *Reader) CacheControl() string + content: func (r *Reader) CacheControl() + string - uid: cloud.google.com/go/storage.Reader.Close name: | func (*Reader) Close @@ -2668,7 +2709,8 @@ items: langs: - go syntax: - content: func (r *Reader) Close() error + content: func (r *Reader) Close() + error - uid: cloud.google.com/go/storage.Reader.ContentEncoding name: | func (*Reader) ContentEncoding @@ -2682,7 +2724,8 @@ items: langs: - go syntax: - content: func (r *Reader) ContentEncoding() string + content: func (r *Reader) ContentEncoding() + string - uid: cloud.google.com/go/storage.Reader.ContentType name: | func (*Reader) ContentType @@ -2696,7 +2739,8 @@ items: langs: - go syntax: - content: func (r *Reader) ContentType() string + content: func (r *Reader) ContentType() + string - uid: cloud.google.com/go/storage.Reader.LastModified name: | func (*Reader) LastModified @@ -2710,8 +2754,9 @@ items: langs: - go syntax: - content: func (r *Reader) LastModified() (time.Time, error) + content: func (r *Reader) LastModified() + (time.Time, + error) - uid: cloud.google.com/go/storage.Reader.Read name: | func (*Reader) Read @@ -2721,8 +2766,9 @@ items: langs: - go syntax: - content: func (r *Reader) Read(p []byte) - (int, error) + content: func (r *Reader) Read(p + []byte) (int, + error) - uid: cloud.google.com/go/storage.Reader.Remain name: | func (*Reader) Remain @@ -2734,7 +2780,8 @@ items: langs: - go syntax: - content: func (r *Reader) Remain() int64 + content: func (r *Reader) Remain() + int64 - uid: cloud.google.com/go/storage.Reader.Size name: | func (*Reader) Size @@ -2750,7 +2797,8 @@ items: langs: - go syntax: - content: func (r *Reader) Size() int64 + content: func (r *Reader) Size() + int64 - uid: cloud.google.com/go/storage.ReaderObjectAttrs name: ReaderObjectAttrs id: ReaderObjectAttrs @@ -2870,11 +2918,11 @@ items: Style provides options for the type of URL to use. Options are\n\t// PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See\n\t// https://cloud.google.com/storage/docs/request-endpoints for details.\n\t// Only supported for V4 signing.\n\t// Optional.\n\tStyle URLStyle\n\n\t// Insecure determines whether the signed - URL should use HTTPS (default) or\n\t// HTTP.\n\t// Only supported for V4 signing.\n\t// - Optional.\n\tInsecure bool\n\n\t// + href=\"#cloud_google_com_go_storage_URLStyle\">URLStyle\n\n\t// Insecure + determines whether the signed URL should use HTTPS (default) or\n\t// HTTP.\n\t// + Only supported for V4 signing.\n\t// Optional.\n\tInsecure bool\n\n\t// Scheme determines the version of URL signing to use. Default is\n\t// SigningSchemeV2.\n\tScheme - SigningScheme\n}" + SigningScheme\n}" - uid: cloud.google.com/go/storage.SigningScheme name: SigningScheme id: SigningScheme @@ -2895,7 +2943,7 @@ items: - go syntax: content: "const (\n\t// SigningSchemeDefault is presently V2 and will change to - V4 in the future.\n\tSigningSchemeDefault SigningScheme + V4 in the future.\n\tSigningSchemeDefault SigningScheme = iota\n\n\t// SigningSchemeV2 uses the V2 scheme to sign URLs.\n\tSigningSchemeV2\n\n\t// SigningSchemeV4 uses the V4 scheme to sign URLs.\n\tSigningSchemeV4\n)" @@ -2931,7 +2979,7 @@ items: - go syntax: content: func BucketBoundHostname(hostname string) - URLStyle + URLStyle - uid: cloud.google.com/go/storage.URLStyle.PathStyle name: | func PathStyle @@ -2944,7 +2992,7 @@ items: langs: - go syntax: - content: func PathStyle() URLStyle + content: func PathStyle() URLStyle - uid: cloud.google.com/go/storage.URLStyle.VirtualHostedStyle name: | func VirtualHostedStyle @@ -2957,7 +3005,7 @@ items: langs: - go syntax: - content: func VirtualHostedStyle() URLStyle + content: func VirtualHostedStyle() URLStyle - uid: cloud.google.com/go/storage.UniformBucketLevelAccess name: UniformBucketLevelAccess id: UniformBucketLevelAccess @@ -2986,7 +3034,7 @@ items: syntax: content: "type Writer struct {\n\t// ObjectAttrs are optional attributes to set on the object. Any attributes\n\t// must be initialized before the first Write - call. Nil or zero-valued\n\t// attributes are ignored.\n\tObjectAttrs\n\n\t// + call. Nil or zero-valued\n\t// attributes are ignored.\n\tObjectAttrs\n\n\t// SendCRC specifies whether to transmit a CRC32C field. It should be set\n\t// to true in addition to setting the Writer's CRC32C field, because zero\n\t// is a valid CRC and normally a zero would not be transmitted.\n\t// If a CRC32C @@ -3026,7 +3074,8 @@ items: langs: - go syntax: - content: func (w *Writer) Attrs() *ObjectAttrs + content: func (w *Writer) Attrs() + *ObjectAttrs - uid: cloud.google.com/go/storage.Writer.Close name: | func (*Writer) Close @@ -3040,7 +3089,8 @@ items: langs: - go syntax: - content: func (w *Writer) Close() error + content: func (w *Writer) Close() + error - uid: cloud.google.com/go/storage.Writer.CloseWithError name: | func (*Writer) CloseWithError @@ -3055,8 +3105,8 @@ items: langs: - go syntax: - content: func (w *Writer) CloseWithError(err error) - error + content: func (w *Writer) CloseWithError(err + error) error - uid: cloud.google.com/go/storage.Writer.Write name: | func (*Writer) Write @@ -3076,8 +3126,9 @@ items: langs: - go syntax: - content: func (w *Writer) Write(p []byte) - (n int, err error) + content: func (w *Writer) Write(p + []byte) (n int, + err error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif @@ -3125,8 +3176,8 @@ items: - go syntax: content: func SignedURL(bucket, name string, - opts *SignedURLOptions) (string, - error) + opts *SignedURLOptions) + (string, error) codeexamples: - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"time\"\n)\n\nfunc main() {\n\tpkey, err := ioutil.ReadFile(\"my-private-key.pem\")\n\tif err !=