Categorygithub.com/hairyhenderson/go-codeowners
modulepackage
0.7.0
Repository: https://github.com/hairyhenderson/go-codeowners.git
Documentation: pkg.go.dev

# README

Go Reference Build

go-codeowners

A package that finds and parses CODEOWNERS files.

Features:

  • operates on local repos
  • doesn't require a cloned repo (i.e. doesn't need a .git directory to be present at the repo's root)
  • can be called from within a repo (doesn't have to be at the root)
  • will find CODEOWNERS files in all documented locations: the repo's root, docs/, and .github/ (or .gitlab/ for GitLab repos)

Usage

go get -u github.com/hairyhenderson/go-codeowners

To find the owner of the README.md file:

import "github.com/hairyhenderson/go-codeowners"

func main() {
	c, _ := FromFile(cwd())
	owners := c.Owners("README.md")
	for i, o := range owners {
		fmt.Printf("Owner #%d is %s\n", i, o)
	}
}

See the docs for more information.

License

The MIT License

Copyright (c) 2018-2023 Dave Henderson

# Functions

FromFile creates a Codeowners from the path to a local file.
FromFileWithFS creates a Codeowners from the path to a file relative to the given filesystem.
FromReader creates a Codeowners from a given Reader instance and root path.
NewCodeowner -.
Deprecated: Use [FromFile] instead.

# Variables

ErrNoCodeownersFound is returned when no CODEOWNERS file is found.

# Structs

Codeowner - owners for a given pattern.
Codeowners - patterns/owners mappings for the given repo.