[go-nuts] Get dependency from enterprise repository

2018-10-08 Thread pprasanthi via golang-nuts
 

I have built and published the go dependencies to our enterprise 
artifactory.
Is there an efficient way to get the files from artifactory and use them in 
test runs?

My dependencies are in jfrog artifactory.
They appear like the following:

   go-local/github.com/davecgh/go-spew/@v/v1.1.1.zip
   go-local/github.com/davecgh/go-spew/@v/v1.1.1.mod


How should I resolve them when I run my tests?

When I set GOPROXY =“value” and tried,

go get github.com/Masterminds/semver

go get github.com/Masterminds/semver: unexpected status 
(http://stg-repo.com/artifactory/github.com/%21masterminds/semver/@v/list): 404 
Not Found

How can I go get the pkg from enterprise proxy and execute my tests?

As a temporary hack I am doing:


Then following

cd **$** {TESTDIR}/src

curl -O http://stg-repo.com/artifactory/ **$** {pkg}

FIELDS=( **$** (echo **$** {pkg} | awk **'{split($0, arr, /[\/:]*/); for (x in 
arr) { print arr[x] }}'** ))

INDEX=( **$** (echo **$** {FIELDS[@]/@v//} | cut -d/ -f1 | wc -w | tr -d **' 
'** ))

PREV_INDEX=$INDEX-1

POST_INDEX=$INDEX+1

FILE= **$** {FIELDS[ **$** {POST_INDEX}]}

unzip **$** {FILE}

FILE= **$** (echo **$** {FILE} | sed -e s/^ **$** {go_local}// -e s/ **$** 
{zip}//)

SOURCE= **$** (find **$** {TESTDIR}/src -name **$** {FIELDS[ **$** 
{PREV_INDEX}]}@ **$** {FILE})

DIR= **$** (dirname $SOURCE)

mv $SOURCE **$** {DIR}/ **$** {FIELDS[ **$** {PREV_INDEX}]}

rm -rf **$** {FILE}.zip

Please let me know the correct way of doing it.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Where are the dependencies saved when we use go mod

2018-10-08 Thread pprasanthi via golang-nuts


I followed below steps to run tests in go mod. In this process I had few 
questions that needs clarification.

   1. cd /tmp/gomodtry/tests/src/hello/hello_test.go
   package tests

import (
“github.com/stretchr/testify/assert”
“os”
“testing”
)

func GetEnv(key string, fallback string) string {
envVariable := os.Getenv(key)
if envVariable == “” {
return fallback
}
return envVariable
}

func TestHello(t *testing.T) {
val := GetEnv(“check”, “ok”)
assert.Equal(t, “ok”, val, “val is not equal to ok”)
}

func TestHello1(t *testing.T) {
val := GetEnv(“check”, “ok”)
assert.Equal(t, “ok”, val, “val is not equal to ok”)
}

   1. 
   
   export GO111MODULE=on
   2. 
   
   go test ./…
   This created go.mod and go.sum files in cd /tmp/gomodtry/ location
   When I executed go test ./… -v again , it executed the tests 
   successfully.
   
QUESTION:

Where is the dependent github.com/stretchr/testify/assert downloaded - I dont 
see it downloaded any where. 
Before go mod concept when we set GOPATH and then go get dependency, it used to 
download physically. 
Can you please explain how the test is resolving dependency without the 
physical presence of dependent library.

In previous version, when we go get dependencies, some times we used to get 500 
error because the host where dependency exists will be down temporarily. 
Do we still face this kind of issues with go mod concepts? How is it handled? 
[we did not like vendoring of dependencies, so we end up doing go get for every 
test run, which made of tests runs unstable when the host went down]

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Where are the dependencies saved when we use go mod

2018-10-08 Thread pprasanthi via golang-nuts
Got it, Thanks Wagner.
I did not set GOPATH since I was using GO111MODULE=on. Since I did not use 
GOPATH I was having a doubt about its physical presence.
But I found in the go root

/Users/xxx/go/pkg/mod/cache

Thanks Again.


On Monday, October 8, 2018 at 2:21:00 PM UTC-7, Wagner Riffel wrote:
>
> > Where is the dependent github.com/stretchr/testify/assert downloaded - 
> I dont see it downloaded any where. 
> it still download physically, it's under $GOPATH/pkg/mod 
> On Mon, Oct 8, 2018 at 5:55 PM pprasanthi via golang-nuts 
> > wrote: 
> > 
> > I followed below steps to run tests in go mod. In this process I had few 
> questions that needs clarification. 
> > 
> > cd /tmp/gomodtry/tests/src/hello/hello_test.go 
> > package tests 
> > 
> > import ( 
> > “github.com/stretchr/testify/assert” 
> > “os” 
> > “testing” 
> > ) 
> > 
> > func GetEnv(key string, fallback string) string { 
> > envVariable := os.Getenv(key) 
> > if envVariable == “” { 
> > return fallback 
> > } 
> > return envVariable 
> > } 
> > 
> > func TestHello(t *testing.T) { 
> > val := GetEnv(“check”, “ok”) 
> > assert.Equal(t, “ok”, val, “val is not equal to ok”) 
> > } 
> > 
> > func TestHello1(t *testing.T) { 
> > val := GetEnv(“check”, “ok”) 
> > assert.Equal(t, “ok”, val, “val is not equal to ok”) 
> > } 
> > 
> > export GO111MODULE=on 
> > 
> > go test ./… 
> > This created go.mod and go.sum files in cd /tmp/gomodtry/ location 
> > When I executed go test ./… -v again , it executed the tests 
> successfully. 
> > 
> > QUESTION: 
> > 
> > Where is the dependent github.com/stretchr/testify/assert downloaded - 
> I dont see it downloaded any where. 
> > Before go mod concept when we set GOPATH and then go get dependency, it 
> used to download physically. 
> > Can you please explain how the test is resolving dependency without the 
> physical presence of dependent library. 
> > 
> > In previous version, when we go get dependencies, some times we used to 
> get 500 error because the host where dependency exists will be down 
> temporarily. 
> > Do we still face this kind of issues with go mod concepts? How is it 
> handled? [we did not like vendoring of dependencies, so we end up doing go 
> get for every test run, which made of tests runs unstable when the host 
> went down] 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] How to resolve go lang dependencies from enterprise repository

2018-10-08 Thread pprasanthi via golang-nuts


I have built and published the go dependencies to our enterprise 
artifactory.
Is there an efficient way to get the files from artifactory and use them in 
test runs?

My dependencies are in jfrog artifactory.
They appear like the following:

   go-local/github.com/davecgh/go-spew/@v/v1.1.1.zip
   go-local/github.com/davecgh/go-spew/@v/v1.1.1.mod


How should I resolve them when I run my tests?

When I set GOPROXY =“value” and tried,

go get github.com/Masterminds/semver

go get github.com/Masterminds/semver: unexpected status 
(http://stg-repo.org.com/artifactory/github.com/%21masterminds/semver/@v/list): 
404 Not Found

How can I go get the pkg from enterprise proxy and execute my tests?

As a temporary hack I am doing:


Then following

cd **$** {TESTDIR}/src

curl -O http://stg-repo.org.com/artifactory/ **$** {pkg}

FIELDS=( **$** (echo **$** {pkg} | awk **'{split($0, arr, /[\/:]*/); for (x in 
arr) { print arr[x] }}'** ))

INDEX=( **$** (echo **$** {FIELDS[@]/@v//} | cut -d/ -f1 | wc -w | tr -d **' 
'** ))

PREV_INDEX=$INDEX-1

POST_INDEX=$INDEX+1

FILE= **$** {FIELDS[ **$** {POST_INDEX}]}

unzip **$** {FILE}

FILE= **$** (echo **$** {FILE} | sed -e s/^ **$** {go_local}// -e s/ **$** 
{zip}//)

SOURCE= **$** (find **$** {TESTDIR}/src -name **$** {FIELDS[ **$** 
{PREV_INDEX}]}@ **$** {FILE})

DIR= **$** (dirname $SOURCE)

mv $SOURCE **$** {DIR}/ **$** {FIELDS[ **$** {PREV_INDEX}]}

rm -rf **$** {FILE}.zip

Please let me know the correct way of doing it.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.