versions

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 5 Imported by: 0

README

versions

Go Report Card Circle CI

versions is a Go program for generating a report in Markdown of used packages from different repositories.

Installing

  • Using go (< 11.1): go install github.com/MarioCarrion/versions/cmd/versions or download a precompiled release.
  • Using go (>= 1.11): GO111MODULE=on go get github.com/MarioCarrion/versions/cmd/versions,
  • Using it as a dependency with the tools.go paradigm:
// +build tools

package tools

import (
	_ "github.com/MarioCarrion/versions/cmd/versions"
)

Using

After installing you can use:

versions <full path to 1 go.mod> <full path to 2 go.mod> <full path to N go.mod>

Example

Using

versions ~/Repositories/versions/go.mod ~/Repositories/nit/go.mod

The following output will be generated:

| | github.com/MarioCarrion/nit  | github.com/MarioCarrion/versions  |
|--- | :---:  | :---:  |
| :white_check_mark: Go version| 1.13| 1.13
| github.com/golangci/golangci-lint |  v1.23.3  |  v1.23.2  |
| :white_check_mark: github.com/google/go-cmp |  v0.2.0  |    |
| :white_check_mark: github.com/pkg/errors |  v0.8.1  |    |
| :white_check_mark: golang.org/x/mod |    |  v0.2.0  |

Which renders like this in Markdown

github.com/MarioCarrion/nit github.com/MarioCarrion/versions
✅ Go version 1.13 1.13
github.com/golangci/golangci-lint v1.23.3 v1.23.2
✅ github.com/google/go-cmp v0.2.0
✅ github.com/pkg/errors v0.8.1
✅ golang.org/x/mod v0.2.0

Development requirements

Go >= 1.13.6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModFiles

func NewModFiles(files []string) ([]*modfile.File, error)

NewModFiles returns a parsed and sorted (by module name) slice a modfiles.

func PrintMarkdown

func PrintMarkdown(gomods GoMods)

PrintMarkdown outputs the parsed Go modules as Markdown.

func SameVersion

func SameVersion(versions []string) bool

SameVersion indicates whether all values in `versions` are the same, empty strings are ignored.

Types

type GoMods

type GoMods struct {
	Names             []string
	SameGoVersions    bool
	Modules           []Module
	AllVersions       Versions
	SameVersions      Versions
	DifferentVersions Versions
}

func NewGoMods

func NewGoMods(files []string) (GoMods, error)

NewGoMods returns categorized Go Modules depending on versions being used.

type Module

type Module struct {
	GoVersion string
	Packages  map[string]Package
}

type Package

type Package struct {
	Version         string
	IsIndirect      bool
	ReplacedPath    string
	ReplacedVersion string
}

Package is the module being used by the repository Go module.

type Version

type Version struct {
	Name   string
	IsSame bool
}

type Versions

type Versions []Version

func (Versions) Len

func (v Versions) Len() int

Len is the number of elements in the collection.

func (Versions) Less

func (v Versions) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Versions) Swap

func (v Versions) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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