Skip to content

Commit

Permalink
Fixup existing docs and add missing docs.
Browse files Browse the repository at this point in the history
Testing Done:
CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/77389176

Bugs closed: 2074

Reviewed at https://rbcommons.com/s/twitter/r/2708/
  • Loading branch information
jsirois committed Aug 26, 2015
1 parent d3987fc commit 52995c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions contrib/go/src/python/pants/contrib/go/targets/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ python_library(
name='go_binary',
sources=['go_binary.py'],
dependencies=[
'contrib/go/src/python/pants/contrib/go/targets:go_local_source',
':go_local_source',
],
)

python_library(
name='go_library',
sources=['go_library.py'],
dependencies=[
'contrib/go/src/python/pants/contrib/go/targets:go_local_source',
':go_local_source',
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@


class GoBinary(GoLocalSource):
pass
"""Represents a local Go main package."""
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@


class GoLibrary(GoLocalSource):
pass
"""Represents a local Go package."""
15 changes: 2 additions & 13 deletions contrib/go/src/python/pants/contrib/go/targets/go_local_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,13 @@ class GoLocalSource(GoTarget):

@classmethod
def is_go_source(cls, path):
"""Returns `True` if the file at the given `path` is a go source file."""
return path.endswith('.go') and os.path.isfile(path)

@classmethod
def local_import_path(cls, source_root, address):
"""Returns the Go import path for the given address housed under the given source root.
A remote package path is the portion of the remote Go package's import path after the remote
root path.
For example, the remote import path 'https://github.com/bitly/go-simplejson' has
a remote root of 'https://github.com/bitly/go-simplejson' and there is only 1 package
in that remote root. The package path in this case is '' or '.' and is normalized
to ''.
Some remote roots have no root package and others have both a root and sub-packages. The
remote root of 'github.com/docker/docker' is an example of the former. One of the packages
you might import from it is 'github.com/docker/docker/daemon/events' and that package has a
normalized remote package path of 'daemon/events'.
:param string source_root: The path of the source root the address is found within.
:param address: The target address of a GoLocalSource target.
:type: :class:`pants.base.address.Address`
Expand All @@ -55,4 +43,5 @@ def __init__(self, address=None, payload=None, **kwargs):

@property
def import_path(self):
"""The import path as used in import statements in `.go` source files."""
return self.local_import_path(self.target_base, self.address)

0 comments on commit 52995c5

Please sign in to comment.