depsy

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 2 Imported by: 7

README

PkgGoDev GoReportCard Code Climate Maintainability Codebeat badge
Coverage Status GitHub Actions CI Status GitHub Actions CodeQL Status

InstallationUsage exampleCI StatusContributingLicense


depsy is simple Go package with minimal dependencies for parsing dependencies info in from go.mod files.

FAQ

Q: Why should I use depsy instead of using runtime/debug.ReadBuildInfo() for reading already embedded info?

A: First of all — size:

Binary Size (in bytes)
Original binary 1819094
depsy + embedded go.mod 1861531 (+ 42,437)
runtime/debug 1891541 (+ 72,447)

Second reason — with debug package, you can't print only direct dependencies.

Installation

Make sure you have a working Go 1.18+ workspace (instructions), then:

go get github.com/essentialkaos/depsy

Usage example

package main

import (
  _ "embed"

  "fmt"

  "github.com/essentialkaos/depsy"
)

//go:embed go.mod
var modules []byte

func main() {
  deps := depsy.Extract(modules, false)

  for _, dep := range deps {
    fmt.Println(dep)
  }
}

CI Status

Branch Status
master CI
develop CI

Contributing

Before contributing to this project please read our Contributing Guidelines.

License

Apache License, Version 2.0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies added in v1.1.0

type Dependencies []Dependency

Dependencies is slice with dependencies info

func Extract

func Extract(data []byte, withIndirect bool) Dependencies

Extract extracts data from go.mod data

Example
data, err := os.ReadFile("go.mod")

if err != nil {
	panic(err.Error())
}

deps := Extract(data, true)

for _, dep := range deps {
	fmt.Println(dep)
}
Output:

type Dependency

type Dependency struct {
	Path    string
	Version string
	Extra   string
}

Dependency contains info about used module

func (Dependency) PrettyPath added in v1.3.0

func (d Dependency) PrettyPath() string

PrettyPath strips major version info from the path

func (Dependency) String added in v1.1.0

func (d Dependency) String() string

String returns string representation of dependency

Jump to

Keyboard shortcuts

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