Ok, I think I have a valid issue that raises to the rank of allowing me to post into this awesome forum for an awesome language. :)I have a constant problem across two Linux developer VMs over the last several months. Both are running Debian (one stable, one testing). They both experience this issue off and on, and today it has cost me too much time to the point that I just copied all files locally to get past this block.It is an issue with developing my own packages - both for internal (private repos) and external uses.Problem: Once I import them into another executable/main() app, and then I go back and modify that package, the changes to the package are not detected by the main() app I imported it into, built and used before. go build, go clean, go test, etc does not bring in the changes.
The process is:* I create a package at ~/go/src/github.com/eduncan911/mypackage* Write some code, tests, etc. It all works.* Commit code to remote repo.* I create an app at ~/go/src/github.com/eduncan911/mymainapp* I reference the first package, build mymainapp, go test, run it, etc.Problem: Now, I go back and edit the original `mypackage` - the changes do not take affect in mymainapp.** most of the time. sometimes, the package changes are picked up right away like they should be.
On Thursday, 30 October 2014 08:09:22 UTC+11, edunc...@gmail.com wrote:Ok, I think I have a valid issue that raises to the rank of allowing me to post into this awesome forum for an awesome language. :)I have a constant problem across two Linux developer VMs over the last several months. Both are running Debian (one stable, one testing). They both experience this issue off and on, and today it has cost me too much time to the point that I just copied all files locally to get past this block.It is an issue with developing my own packages - both for internal (private repos) and external uses.Problem: Once I import them into another executable/main() app, and then I go back and modify that package, the changes to the package are not detected by the main() app I imported it into, built and used before. go build, go clean, go test, etc does not bring in the changes.You need to use go install to install those packages. http://dave.cheney.net/2014/06/04/what-does-go-build-build
The process is:* I create a package at ~/go/src/github.com/eduncan911/mypackage* Write some code, tests, etc. It all works.* Commit code to remote repo.* I create an app at ~/go/src/github.com/eduncan911/mymainapp* I reference the first package, build mymainapp, go test, run it, etc.Problem: Now, I go back and edit the original `mypackage` - the changes do not take affect in mymainapp.** most of the time. sometimes, the package changes are picked up right away like they should be.This is likely to be a problem with your GOPATH configuration.Can you post the entire output fromgo install -x github.com/eduncan911/mymainapp
Thanks for your reply. For me things are only getting more confusing so I can only offer generic advice.
On 30 Oct 2014 14:23, "Eric Duncan" <edunc...@gmail.com> wrote:
>
> Thanks Dave! Feel honored to get a reply from the guy who floods my tweeter feed. :)
>
> See inlines below.
>
> On Wed, Oct 29, 2014 at 6:50 PM, Dave Cheney <da...@cheney.net> wrote:
>>
>>
>> On Thursday, 30 October 2014 08:09:22 UTC+11, edunc...@gmail.com wrote:
>>>
>>> Ok, I think I have a valid issue that raises to the rank of allowing me to post into this awesome forum for an awesome language. :)
>>>
>>> I have a constant problem across two Linux developer VMs over the last several months. Both are running Debian (one stable, one testing). They both experience this issue off and on, and today it has cost me too much time to the point that I just copied all files locally to get past this block.
>>>
>>> It is an issue with developing my own packages - both for internal (private repos) and external uses.
>>>
>>> Problem: Once I import them into another executable/main() app, and then I go back and modify that package, the changes to the package are not detected by the main() app I imported it into, built and used before. go build, go clean, go test, etc does not bring in the changes.
>>
>>
>> You need to use go install to install those packages. http://dave.cheney.net/2014/06/04/what-does-go-build-build
>>
>
>
> Humm. I actually haven't been doing "go get" or "go install" for these packages I developed locally. I reference them in the tooling, and it has been working (like I said, caching the original version I have locally for 24 hours, then I see changes I made to the package). The tool I use them in, I just referenced as import and they worked. But, I can see how that would work by moving them into the /pkg/ directory.
I don't understand why 24 hours is important, unless the clock on your computer is running backwards.
The go tool, like most build tools compares the time of the source file with the compiled file (in GOPATH/pkg).
>
> And I see the other packages I developed in /pkg/ as well. Now I am thinking that it does get installed somehow with "go get ." on the tooling, and that's why I have a cached version there.
>
Go get checks out the source using the bane of the package to figure out where the source repo lives then calls go install. There isn't any more magic than that, I'd you aren't trying to fetch someone else's changes, you don't need to be online.
> This may be my lack of understanding of how to develop and test (test with external programs) packages locally.
>
> How would I continue to develop/change the package code as I continued to develop the tool/runtime, if it is located in $GOPATH/pkg/
GOPATH/pkg is for use by the go tool, don't touch anything in there
instead of $GOPATH/src/? I ask because I often find myself adding features onto (or changing the API) of those packages I reference as I develop the tooling or what consumes them. Must I, 1) edit package code, 2) push changes up to repo 3) run go install for each small tweak locally?
Nope, just use go install, always and you'll have no problems.
I often times prototype changes in packages, which is something I don't want to commit up to a public repo (which I can get around with branches, sure).
The fact that the source lives in a directory that is under Git's control isn't important to the build process.
>
> (I often develop offline, during my 4 hour commute)
>
>
>>>
>>>
>>> The process is:
>>>
>>> * I create a package at ~/go/src/github.com/eduncan911/mypackage
>>> * Write some code, tests, etc. It all works.
>>> * Commit code to remote repo.
>>> * I create an app at ~/go/src/github.com/eduncan911/mymainapp
>>> * I reference the first package, build mymainapp, go test, run it, etc.
>>>
>>> Problem: Now, I go back and edit the original `mypackage` - the changes do not take affect in mymainapp.*
>>> * most of the time. sometimes, the package changes are picked up right away like they should be.
>>
>>
>> This is likely to be a problem with your GOPATH configuration.
>>
>> Can you post the entire output from
>>
>> go install -x github.com/eduncan911/mymainapp
>
>
> I think you meant the package, not the /mymainapp? For /mymainapp, it's located in a sub-sub-sub folder of other tools outside of my gopath. So, if i run go install on it, it looks like this:
>
Ok, this is probably the problem,
1. Don't use symlinks to symlink source into your GOPATH, the go tool will ignore it
2. Move all your go code into your GOPATH
3. If your GOPATH contains multiple elements, collapse them into a single element.
Then everything will work properly.
Thanks for your reply. For me things are only getting more confusing so I can only offer generic advice.
On 30 Oct 2014 14:23, "Eric Duncan" <edunc...@gmail.com> wrote:
>
> Thanks Dave! Feel honored to get a reply from the guy who floods my tweeter feed. :)
>
> See inlines below.
>
> On Wed, Oct 29, 2014 at 6:50 PM, Dave Cheney <da...@cheney.net> wrote:
>>
>>
>> On Thursday, 30 October 2014 08:09:22 UTC+11, edunc...@gmail.com wrote:
>>>
>>> Ok, I think I have a valid issue that raises to the rank of allowing me to post into this awesome forum for an awesome language. :)
>>>
>>> I have a constant problem across two Linux developer VMs over the last several months. Both are running Debian (one stable, one testing). They both experience this issue off and on, and today it has cost me too much time to the point that I just copied all files locally to get past this block.
>>>
>>> It is an issue with developing my own packages - both for internal (private repos) and external uses.
>>>
>>> Problem: Once I import them into another executable/main() app, and then I go back and modify that package, the changes to the package are not detected by the main() app I imported it into, built and used before. go build, go clean, go test, etc does not bring in the changes.
>>
>>
>> You need to use go install to install those packages. http://dave.cheney.net/2014/06/04/what-does-go-build-build
>>
>
>
> Humm. I actually haven't been doing "go get" or "go install" for these packages I developed locally. I reference them in the tooling, and it has been working (like I said, caching the original version I have locally for 24 hours, then I see changes I made to the package). The tool I use them in, I just referenced as import and they worked. But, I can see how that would work by moving them into the /pkg/ directory.
I don't understand why 24 hours is important, unless the clock on your computer is running backwards.
The go tool, like most build tools compares the time of the source file with the compiled file (in GOPATH/pkg).
>
> And I see the other packages I developed in /pkg/ as well. Now I am thinking that it does get installed somehow with "go get ." on the tooling, and that's why I have a cached version there.
>
Go get checks out the source using the bane of the package to figure out where the source repo lives then calls go install. There isn't any more magic than that, I'd you aren't trying to fetch someone else's changes, you don't need to be online.
> This may be my lack of understanding of how to develop and test (test with external programs) packages locally.
>
> How would I continue to develop/change the package code as I continued to develop the tool/runtime, if it is located in $GOPATH/pkg/
GOPATH/pkg is for use by the go tool, don't touch anything in there
instead of $GOPATH/src/? I ask because I often find myself adding features onto (or changing the API) of those packages I reference as I develop the tooling or what consumes them. Must I, 1) edit package code, 2) push changes up to repo 3) run go install for each small tweak locally?
Nope, just use go install, always and you'll have no problems.
I often times prototype changes in packages, which is something I don't want to commit up to a public repo (which I can get around with branches, sure).
The fact that the source lives in a directory that is under Git's control isn't important to the build process.
>
> (I often develop offline, during my 4 hour commute)
>
>
>>>
>>>
>>> The process is:
>>>
>>> * I create a package at ~/go/src/github.com/eduncan911/mypackage
>>> * Write some code, tests, etc. It all works.
>>> * Commit code to remote repo.
>>> * I create an app at ~/go/src/github.com/eduncan911/mymainapp
>>> * I reference the first package, build mymainapp, go test, run it, etc.
>>>
>>> Problem: Now, I go back and edit the original `mypackage` - the changes do not take affect in mymainapp.*
>>> * most of the time. sometimes, the package changes are picked up right away like they should be.
>>
>>
>> This is likely to be a problem with your GOPATH configuration.
>>
>> Can you post the entire output from
>>
>> go install -x github.com/eduncan911/mymainapp
>
>
> I think you meant the package, not the /mymainapp? For /mymainapp, it's located in a sub-sub-sub folder of other tools outside of my gopath. So, if i run go install on it, it looks like this:
>
Ok, this is probably the problem,
1. Don't use symlinks to symlink source into your GOPATH, the go tool will ignore it
2. Move all your go code into your GOPATH
3. If your GOPATH contains multiple elements, collapse them into a single element.
Then everything will work properly.
Wouldn't that install the tool as well? (which is not my intension)
Good point. It wouldn't hurt anything. Though, for example, a tool I am working right now talks to (requires) 4 APIs + RabbitMQ - none of which I have installed locally.
go install && go run X -params...
^- yes, that is shorter now that I think of it. :-)