gddo: Index | Files

package gosrc

import ""

Package gosrc fetches Go package source code from version control services.


Package Files

bitbucket.go build.go client.go data.go github.go golang.go google.go gosrc.go launchpad.go local.go path.go present.go util.go vcs.go


const ExpiresAfter = 2 * 365 * 24 * time.Hour // Package with no commits and imports expires.


var TempDir = filepath.Join(os.TempDir(), "gddo")

Store temporary data in this directory.

func GetGitHubUpdates Uses

func GetGitHubUpdates(ctx context.Context, client *http.Client, pushedAfter string) (maxPushedAt string, names []string, err error)

GetGitHubUpdates returns the full names ("owner/repo") of recently pushed GitHub repositories. by pushedAfter.

func IsGoRepoPath Uses

func IsGoRepoPath(path string) bool

IsGoRepoPath returns true if path is in $GOROOT/src.

func IsNotFound Uses

func IsNotFound(err error) bool

IsNotFound returns true if err is of type NotFoundError.

func IsValidPath Uses

func IsValidPath(importPath string) bool

IsValidPath returns true if importPath is structurally valid.

func IsValidRemotePath Uses

func IsValidRemotePath(importPath string) bool

IsValidRemotePath returns true if importPath is structurally valid for "go get".

func MaybeRedirect Uses

func MaybeRedirect(importPath, importComment, resolvedGitHubPath string) error

MaybeRedirect uses the provided import path, import comment, and resolved GitHub path to make a decision of whether to redirect to another, more canonical import path. It returns nil error to indicate no redirect, or a NotFoundError error to redirect.

func OverwriteLineComments Uses

func OverwriteLineComments(p []byte)

func SetLocalDevMode Uses

func SetLocalDevMode(path string)

SetLocalDevMode sets the package to local development mode. In this mode, the GOPATH specified by path is used to find directories instead of version control services.

type Directory Uses

type Directory struct {
    // The import path for this package.
    ImportPath string

    // Import path of package after resolving go-import meta tags, if any.
    ResolvedPath string

    // Import path of package with the canonical user/repo case as reported by
    // the server. Optional.
    // If set, used to ensure canonical case is used when there's no import path
    // comment (e.g., to redirect from "" to
    // "").
    ResolvedGitHubPath string

    // Import path prefix for all packages in the project.
    ProjectRoot string

    // Name of the project.
    ProjectName string

    // Project home page.
    ProjectURL string

    // Version control system: git, hg, bzr, ...
    VCS string

    // Version control: active or should be suppressed.
    Status DirectoryStatus

    // Cache validation tag. This tag is not necessarily an HTTP entity tag.
    // The tag is "" if there is no meaningful cache validation for the VCS.
    Etag string

    // Files.
    Files []*File

    // Subdirectories, not guaranteed to contain Go code.
    Subdirectories []string

    // Location of directory on version control service website.
    BrowseURL string

    // Format specifier for link to source line. It must contain one %s (file URL)
    // followed by one %d (source line number), or be empty string if not available.
    // Example: "%s#L%d".
    LineFmt string

    // Whether the repository of this directory is a fork of another one.
    Fork bool

    // How many stars (for a GitHub project) the repository of this directory has.
    Stars int

Directory describes a directory on a version control service.

func Get Uses

func Get(ctx context.Context, client *http.Client, importPath string, etag string) (dir *Directory, err error)

func (*Directory) Import Uses

func (dir *Directory) Import(ctx *build.Context, mode build.ImportMode) (*build.Package, error)

Import returns details about the package in the directory.

type DirectoryStatus Uses

type DirectoryStatus int
const (
    Active          DirectoryStatus = iota
    DeadEndFork                     // Forks with no commits
    QuickFork                       // Forks with less than 3 commits, all within a week from creation
    NoRecentCommits                 // No commits for ExpiresAfter

    // No commits for ExpiresAfter and no imports.
    // This is a status derived from NoRecentCommits and the imports count information in the db.

type File Uses

type File struct {
    // File name with no directory.
    Name string

    // Contents of the file.
    Data []byte

    // Location of file on version control service website.
    BrowseURL string

File represents a file.

type NotFoundError Uses

type NotFoundError struct {
    // Diagnostic message describing why the directory was not found.
    Message string

    // Redirect specifies the path where package can be found.
    Redirect string

NotFoundError indicates that the directory or presentation was not found.

func (NotFoundError) Error Uses

func (e NotFoundError) Error() string

type NotModifiedError Uses

type NotModifiedError struct {
    Since  time.Time
    Status DirectoryStatus

func (NotModifiedError) Error Uses

func (e NotModifiedError) Error() string

type Presentation Uses

type Presentation struct {
    Filename string
    Files    map[string][]byte
    Updated  time.Time

func GetPresentation Uses

func GetPresentation(ctx context.Context, client *http.Client, importPath string) (*Presentation, error)

GetPresentation gets a presentation from the the given path.

type Project Uses

type Project struct {
    Description string

Project represents a repository.

func GetProject Uses

func GetProject(ctx context.Context, client *http.Client, importPath string) (*Project, error)

GetProject gets information about a repository.

type RemoteError Uses

type RemoteError struct {
    Host string
    // contains filtered or unexported fields

func (*RemoteError) Error Uses

func (e *RemoteError) Error() string

Package gosrc imports 25 packages (graph) and is imported by 376 packages. Updated 2019-09-07. Refresh now. Tools for package owners.