FAQ
Hi all,

I've got a question about how to reference packages from within a project.
Assuming two files in my project "foo" are in separate packages "bar" and
"baz", I can easily enough reference one of those packages from the other
like so...

From foo/baz:

import (
   "foo/bar"
)

But then when I try to import anything from "foo/baz" into another project:

import (
   "github.com/some_user/foo_project/baz"
)

I get errors like:

import "foo/bar": import path doesn't contain a hostname
package foo/bar: unrecognized import path "foo/bar"

Should the imports in "foo/baz" have the hostname for the source repo of
the "foo" project itself in them or am I just missing something else?

Thanks!

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Aug 7, 2013 at 1:18 am

    On Wed, Aug 7, 2013 at 10:41 AM, wrote:

    Hi all,

    I've got a question about how to reference packages from within a project.
    Assuming two files in my project "foo" are in separate packages "bar" and
    "baz", I can easily enough reference one of those packages from the other
    like so...

    From foo/baz:

    import (
    "foo/bar"
    )
    All imports need to be relative to GOPATH.
    If you're hosting your code on github and you want it to be 'go get'able
    then your imports will look something like "
    github.com/yourusername/yourproject/yourpkg"
    Even packages within your project should refer to other packages by their
    full import path.



    But then when I try to import anything from "foo/baz" into another project:

    import (
    "github.com/some_user/foo_project/baz"
    )

    I get errors like:

    import "foo/bar": import path doesn't contain a hostname
    package foo/bar: unrecognized import path "foo/bar"

    Should the imports in "foo/baz" have the hostname for the source repo of
    the "foo" project itself in them or am I just missing something else?

    Thanks!

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    =====================
    http://jessta.id.au

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Stephen Huenneke at Aug 9, 2013 at 3:34 am
    Thanks! It took me a little while to properly wrap my head around GOPATH,
    but now I understand it.

    On Tue, Aug 6, 2013 at 6:18 PM, Jesse McNelis wrote:
    On Wed, Aug 7, 2013 at 10:41 AM, wrote:

    Hi all,

    I've got a question about how to reference packages from within a
    project. Assuming two files in my project "foo" are in separate packages
    "bar" and "baz", I can easily enough reference one of those packages from
    the other like so...

    From foo/baz:

    import (
    "foo/bar"
    )
    All imports need to be relative to GOPATH.
    If you're hosting your code on github and you want it to be 'go get'able
    then your imports will look something like "
    github.com/yourusername/yourproject/yourpkg"
    Even packages within your project should refer to other packages by their
    full import path.



    But then when I try to import anything from "foo/baz" into another
    project:

    import (
    "github.com/some_user/foo_project/baz"
    )

    I get errors like:

    import "foo/bar": import path doesn't contain a hostname
    package foo/bar: unrecognized import path "foo/bar"

    Should the imports in "foo/baz" have the hostname for the source repo of
    the "foo" project itself in them or am I just missing something else?

    Thanks!

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    =====================
    http://jessta.id.au

    --
    ///Stephen - http://sdh.skarilla.com

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 7, '13 at 12:59a
activeAug 9, '13 at 3:34a
posts3
users2
websitegolang.org

2 users in discussion

Stephen Huenneke: 2 posts Jesse McNelis: 1 post

People

Translate

site design / logo © 2022 Grokbase