Documentation ¶
Overview ¶
Package gosrc fetches Go package source code from version control services.
Index ¶
- Constants
- Variables
- func GetGitHubUpdates(ctx context.Context, client *http.Client, pushedAfter string) (maxPushedAt string, names []string, err error)
- func IsGoRepoPath(path string) bool
- func IsNotFound(err error) bool
- func IsValidPath(importPath string) bool
- func IsValidRemotePath(importPath string) bool
- func OverwriteLineComments(p []byte)
- func SetLocalDevMode(path string)
- type Directory
- type DirectoryStatus
- type File
- type NotFoundError
- type NotModifiedError
- type Presentation
- type Project
- type RemoteError
Constants ¶
const ExpiresAfter = 2 * 365 * 24 * time.Hour // Package with no commits and imports expires.
Variables ¶
var TempDir = filepath.Join(os.TempDir(), "gddo")
Store temporary data in this directory.
Functions ¶
func GetGitHubUpdates ¶
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 ¶
IsGoRepoPath returns true if path is in $GOROOT/src.
func IsNotFound ¶
IsNotFound returns true if err is of type NotFoundError.
func IsValidPath ¶
IsValidPath returns true if importPath is structurally valid.
func IsValidRemotePath ¶
IsValidRemotePath returns true if importPath is structurally valid for "go get".
func OverwriteLineComments ¶
func OverwriteLineComments(p []byte)
func SetLocalDevMode ¶
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.
Types ¶
type Directory ¶
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 github.com server. Optional. // If set, used to ensure canonical case is used when there's no import path // comment (e.g., to redirect from "github.com/UsEr/rEpO/dir" to // "github.com/User/Repo/dir"). 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) or followers (for a BitBucket // project) the repository of this directory has. Stars int }
Directory describes a directory on a version control service.
type DirectoryStatus ¶
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. Inactive )
type File ¶
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 ¶
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 ¶
func (e NotFoundError) Error() string
type NotModifiedError ¶
type NotModifiedError struct { Since time.Time Status DirectoryStatus }
func (NotModifiedError) Error ¶
func (e NotModifiedError) Error() string
type Presentation ¶
func GetPresentation ¶
func GetPresentation(ctx context.Context, client *http.Client, importPath string) (*Presentation, error)
GetPresentation gets a presentation from the the given path.
type RemoteError ¶
type RemoteError struct { Host string // contains filtered or unexported fields }
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string