[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#984719: lintian: add check for incomplete XS-Go-Import-Path



Package: lintian
Severity: wishlist
X-Debbugs-CC: pabs@debian.org


Intro
=====

Go packages use the d/control `XS-Go-Import-Path` field to document the
import paths that they provide. This corresponds with files installed
under /usr/share/gocode/src. It would be great if lintian validated that
`XS-Go-Import-Path` was correct.

Xs-Go-Import-Path is used by tools in the Go packaging ecosystem for
useful things like finding the debian packages required to build a
program given its import paths.


XS-Go-Import-Path Usage
=======================

Most packages provide only one import path.

For example, `golang-github-bmizerany-pat` provides `XS-Go-Import-Path:
github.com/bmizerany/pat` and it installs files under
`/usr/share/gocode/src/github.com/bmizernany`.

Some packages provide more import paths. Sometimes via symlinks for
alternate names but sometimes simply because they actually provide two
different packages.

For example, `golang-gopkg-asn1-ber.v1` provides two import paths:
```
XS-Go-Import-Path: gopkg.in/asn1-ber.v1,
                   github.com/go-asn1-ber/asn1-ber
```

And it installs files at both
`/usr/share/gocode/src/gopkg.in/asn1-ber.v1` and
`/usr/share/gocode/src/github.com/go-asn1-ber`



Implementing the check
======================

I am unfamiliar with Lintian internals, and with Perl, but I do have
some pointers:

- If the package installs N directories under `/usr/share/gocode/src` It
should have exactly N import paths.

This package would have one import path (github.com/aviau/project):
 * /usr/share/gocode/src/github.com/aviau/project/aa.go
 * /usr/share/gocode/src/github.com/aviau/project/bb.go


This package would have two import paths (github.com/aviau/project and
gitlab.com/aviau/project):
 * /usr/share/gocode/src/github.com/aviau/project/aa.go
 * /usr/share/gocode/src/github.com/aviau/project/bb.go
 * /usr/share/gocode/src/gitlab.com/aviau/project (symlink)

- If the package installs files under
`/usr/share/gocode/src/FOO.com/BAR`, one of its import paths should
start with `foo.com/bar`.


aviau/identify-incomplete-xs-go-import-path
===========================================

I have written a python program to try and detect those mistakes, but it
only covers some use cases and depends on Debian Code Search. However it
may be useful for anyone trying to write a lintian check:
- https://salsa.debian.org/aviau/identify-incomplete-xs-go-import-path


Thank you for Lintian and thanks for taking a look at this :)

-- 
Aleaxandre Viau
aviau@debian.org


Reply to: