librariesio / bibliothecary

:notebook_with_decorative_cover: Libraries.io Package Manager Manifest Parsers
https://libraries.io/rubygems/bibliothecary
GNU Affero General Public License v3.0
89 stars 36 forks source link

Bibliothecary::Parsers::Go: pass "direct: true|false" back from go.mod deps #594

Closed tiegz closed 2 months ago

tiegz commented 2 months ago

go.mod is both a manifest and a lockfile: direct deps are defined there, but Go Modules will also record indirect deps there with an // indirect suffix, e.g.:

require golang.org/x/net v1.2.3 // indirect

(specifically, this means that the dep isn't used in any packages of the given app, but it is used by one of the app's dependencies. See the docs here)

this change will introduce a new direct key to Bibliothecary's returned list of dependencies -- only for Go so far -- so that downstream users can use that data (instead of the typical "if it's in manifest it's direct, otherwise it's transitive"):

      ...
      { name: "github.com/replicon/fast-archiver",
        requirement: "v0.0.0-20121220195659-060bf9adec25",
        type: "runtime",
        direct: false,
      },
      {
        name: "gopkg.in/yaml.v1",
        requirement: "v1.0.0-20140924161607-9f9df34309c0",
        type: "runtime",
        direct: true,
      },
      ...