Help us shape the future of Go! Take the 2026 Go Developer Survey

findpackagesrc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

findpackagesrc

Golang package that find original source path

package main

import (
    "fmt"
    "github.com/shibukawa/findpackagesrc"
)

func main() {
    finder, err := findpackagesrc.NewFinder(findpackagesrc.Option{})
    if err != nil {
        panic(err)
    }
    path, err := finder.FindSourcePath("github.com/stretchr/testify")
    if err != nil {
        panic(err)
    }
    fmt.Println(path)
    // /home/yourname/go/pkg/mod/github.com/stretchr/testify@v1.4.0
}

Documentation

Overview

findpackagesrc package provides API to detect original source of go package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder has method returns package source

func NewFinder

func NewFinder(option Option) (*Finder, error)

NewFinder is a constructor function of Finder

func (Finder) FindSourcePath

func (f Finder) FindSourcePath(pkg string) (string, error)

FindSourcePath returns source folder of specified package

type ModType

type ModType int
const (
	Module ModType = iota + 1
	LocalPath
)

type Option

type Option struct {
	PkgPath string
	GoPath  string
}

Option specify Finder's option

Default value of PkgPath is a nearest parent folder that contains go.mod.

Default value of GoPath is a $GOPATH.

Jump to

Keyboard shortcuts

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