swh.loader.package.golang.loader module#

class swh.loader.package.golang.loader.GolangPackageInfo(url: str, filename: Optional[str], version: str, name: str, timestamp: Optional[TimestampWithTimezone], *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#

Bases: BasePackageInfo

Method generated by attrs for class GolangPackageInfo.

class swh.loader.package.golang.loader.GolangLoader(storage: StorageInterface, url: str, max_content_size: Optional[int] = None, **kwargs)[source]#

Bases: PackageLoader[GolangPackageInfo]

Load Golang module zip file into SWH archive.

Loader’s constructor. This raises exception if the minimal required

configuration is missing (cf. fn:check method).

Parameters:
  • storage – Storage instance

  • url – Origin url to load data from

visit_type: str = 'golang'#
GOLANG_PKG_DEV_URL = 'https://pkg.go.dev'#
GOLANG_PROXY_URL = 'https://proxy.golang.org'#
get_versions() Sequence[str][source]#

Return the list of all published package versions.

Raises:

classswh.loader.exception.NotFound error when failing to read the published package versions.

Returns:

Sequence of published versions

get_default_version() str[source]#

Retrieve the latest release version if any.

Returns:

Latest version

get_package_info(version: str) Iterator[Tuple[str, GolangPackageInfo]][source]#
Given a release version of a package, retrieve the associated

package information for such version.

Parameters:

version – Package version

Returns:

(branch name, package metadata)

build_release(p_info: GolangPackageInfo, uncompressed_path: str, directory: bytes) Optional[Release][source]#

Build the release from the archive metadata (extrinsic artifact metadata) and the intrinsic metadata.

Parameters:
  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

origin: Origin#
loaded_snapshot_id: Optional[bytes]#
parent_origins: Optional[List[Origin]]#

If the given origin is a “forge fork” (ie. created with the “Fork” button of GitHub-like forges), build_extrinsic_origin_metadata() sets this to a list of origins it was forked from; closest parent first.