From ff0519565c10727ffbd2846b4e3d5c22a585287d Mon Sep 17 00:00:00 2001 From: "Lixia (Sylvia) Lei" Date: Mon, 5 Dec 2022 18:42:00 +0800 Subject: [PATCH] doc: make the default options displayed next to the option type on godoc (#372) **Typed** constants/variables are displayed next to the declaration of their type. Resolves #304 Signed-off-by: Lixia (Sylvia) Lei --- copy.go | 17 ++++++++--------- extendedcopy.go | 19 +++++++++---------- pack.go | 12 +++++------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/copy.go b/copy.go index 9106827b..97c47438 100644 --- a/copy.go +++ b/copy.go @@ -36,18 +36,14 @@ import ( // defaultConcurrency is the default value of CopyGraphOptions.Concurrency. const defaultConcurrency = 3 // This value is consistent with dockerd and containerd. -var ( - // DefaultCopyOptions provides the default CopyOptions. - DefaultCopyOptions = CopyOptions{ - CopyGraphOptions: DefaultCopyGraphOptions, - } - // DefaultCopyGraphOptions provides the default CopyGraphOptions. - DefaultCopyGraphOptions CopyGraphOptions -) - // errSkipDesc signals copyNode() to stop processing a descriptor. var errSkipDesc = errors.New("skip descriptor") +// DefaultCopyOptions provides the default CopyOptions. +var DefaultCopyOptions CopyOptions = CopyOptions{ + CopyGraphOptions: DefaultCopyGraphOptions, +} + // CopyOptions contains parameters for oras.Copy. type CopyOptions struct { CopyGraphOptions @@ -86,6 +82,9 @@ func (opts *CopyOptions) WithTargetPlatform(p *ocispec.Platform) { // CopyGraphOptions.MaxMetadataBytes. const defaultCopyMaxMetadataBytes int64 = 4 * 1024 * 1024 // 4 MiB +// DefaultCopyGraphOptions provides the default CopyGraphOptions. +var DefaultCopyGraphOptions CopyGraphOptions + // CopyGraphOptions contains parameters for oras.CopyGraph. type CopyGraphOptions struct { // Concurrency limits the maximum number of concurrent copy tasks. diff --git a/extendedcopy.go b/extendedcopy.go index 4ad3f8b3..e51a5bbe 100644 --- a/extendedcopy.go +++ b/extendedcopy.go @@ -29,22 +29,21 @@ import ( "oras.land/oras-go/v2/registry" ) -var ( - // DefaultExtendedCopyOptions provides the default ExtendedCopyOptions. - DefaultExtendedCopyOptions = ExtendedCopyOptions{ - ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions, - } - // DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions. - DefaultExtendedCopyGraphOptions = ExtendedCopyGraphOptions{ - CopyGraphOptions: DefaultCopyGraphOptions, - } -) +// DefaultExtendedCopyOptions provides the default ExtendedCopyOptions. +var DefaultExtendedCopyOptions ExtendedCopyOptions = ExtendedCopyOptions{ + ExtendedCopyGraphOptions: DefaultExtendedCopyGraphOptions, +} // ExtendedCopyOptions contains parameters for oras.ExtendedCopy. type ExtendedCopyOptions struct { ExtendedCopyGraphOptions } +// DefaultExtendedCopyGraphOptions provides the default ExtendedCopyGraphOptions. +var DefaultExtendedCopyGraphOptions ExtendedCopyGraphOptions = ExtendedCopyGraphOptions{ + CopyGraphOptions: DefaultCopyGraphOptions, +} + // ExtendedCopyGraphOptions contains parameters for oras.ExtendedCopyGraph. type ExtendedCopyGraphOptions struct { CopyGraphOptions diff --git a/pack.go b/pack.go index cb8bf3b6..5880c3b1 100644 --- a/pack.go +++ b/pack.go @@ -38,13 +38,11 @@ const ( MediaTypeUnknownArtifact = "application/vnd.unknown.artifact.v1" ) -var ( - // ErrInvalidDateTimeFormat is returned by Pack() when - // AnnotationArtifactCreated or AnnotationCreated is provided, but its value - // is not in RFC 3339 format. - // Reference: https://www.rfc-editor.org/rfc/rfc3339#section-5.6 - ErrInvalidDateTimeFormat = errors.New("invalid date and time format") -) +// ErrInvalidDateTimeFormat is returned by Pack() when +// AnnotationArtifactCreated or AnnotationCreated is provided, but its value +// is not in RFC 3339 format. +// Reference: https://www.rfc-editor.org/rfc/rfc3339#section-5.6 +var ErrInvalidDateTimeFormat = errors.New("invalid date and time format") // PackOptions contains parameters for oras.Pack. type PackOptions struct {