target

package
v0.54.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RemoteRepoUrlFlagname = "remote-repo-url"
)

Variables

This section is empty.

Functions

func GetTargetId

func GetTargetId(path string, idType TargetIdType, options ...TargetIdOptions) (string, error)

GetTargetId generates an identifier for a given path. The format and components of the ID vary depending on whether the path points to a git repository or a file system location.

scheme:type/namespace/name@version?qualifiers#subpath

The URL scheme is always "pkg".

For git repositories, the URL structure is as follows:

pkg:git/namespace@version?branch=branchname[subpath]

- namespace: MUST be the hostname and path of the repository (e.g., "github.com/user/repo")
- name: MUST be the project name (derived from the repository URL)
- version: MUST be the commit hash
- branch (qualifiers): MUST be the branch name
- subpath (optional): COULD specify a path or file within the repository
- issue (qualifiers) (optional): COULD specify an issue ID
- line (qualifiers) (optional): COULD specify a line number, often used with issue qualifiers

Example for a git repository:

pkg:git/github.com/snyk/go-application-framework@c9cc908c69bc6d8cc4715275f9c19fa3be69aebc?branch=main

Example for a file within a git repository:

pkg:git/github.com/snyk/go-application-framework@c9cc908c69bc6d8cc4715275f9c19fa3be69aebc?branch=main#cliv2/go.mod

For file system locations, the URL structure is as follows:

pkg:filesystem/namespace/name[subpath]

- namespace: MUST be the SHA-256 sum of the absolute path to the root package/folder
- name: MUST be the last folder name in the path
- subpath (optional): COULD specify a path or file within the directory

Example for a file system location:

pkg:filesystem/aafc908c69bc6d8cc4715275f9c19fa3be69aebc/name#cliv2/go.mod

Parameters: - path: The file system path to generate the target id for. - idType: one of the available TargetIdType - options: optional values to assign to the target id

Returns: A string representing the target id

Types

type TargetIdOptions

type TargetIdOptions func(id *url.URL) (*url.URL, error)

func WithConfiguredRepository

func WithConfiguredRepository(config configuration.Configuration) TargetIdOptions

func WithLineNumber

func WithLineNumber(line int) TargetIdOptions

func WithSubPath

func WithSubPath(subpath string) TargetIdOptions

type TargetIdType

type TargetIdType int
const (
	FilesystemTargetId   TargetIdType = 0x02 // require filesystem type target id otherwise fail
	GitTargetId          TargetIdType = 0x01 // require git type target id otherwise fail
	AutoDetectedTargetId TargetIdType = 0xff // automatically detect the target id type, trying git first and falling back to filesystem
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL