[go-nuts] Need hints on debugging high memory usage after go 1.11 upgrade
Good day fellow gophers. A system program of mine that runs couple of server daemons in one executable used to consume ~15MB of resident memory and ~15MB of virtual memory, compiled with go 1.10. After upgrading to go 1.11, its resident memory usage remains identical, but virtual memory usage shoots up to 112MB. Since the program locks its memory for safety, the virtual memory usage becomes very noticeable. According to "viewcore" utility, the significant increase of virtual memory usage corresponds to significant increase in "free spans - retained (kept for reuse by Go)". Because the program exclusive uses standard library, I wish to narrow down the library that causes the memory usage spike and make a bug report. But how do I go about looking for this standard library, if removal of any causes a cascading chain of compilation errors? Thanks! The program is an open source software: https://github.com/HouzuoGuo/laitos/ Kind regards, Howard -- 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] Profiling CGO application
On Tue, Oct 9, 2018 at 11:57 AM, Vitaly Isaev wrote: > > This topic has been already discussed here last year, but I would like to > bring it up again, because some details in Go 1.11 could be changed (compared > with Go 1.8). The problem is CPU profiling of Go application that actively > uses C / C++ libraries via CGO interface. Pprof can't determine which C/C++ > function utilizes CPU. It's unsupported, but see if it helps to blank import github.com/ianlancetaylor/cgosymbolizer . Ian -- 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] Re: Importing local package
Forgive my ignorance, I am working from MacOS but realized my mistake about 20 min after I had submitted the issue I was having. The import wasnt really the issue, it was my usage of the QueryESXi function. I was trying to call it directly but figured out after a few hours of frustration and googling that `cli.QueryESXi()` fixed my issue. Super noob mistake on my part. I apologize for wasting the communities time on something so trivial and appreciate the responses. Thanks! On Tuesday, October 9, 2018 at 1:21:38 PM UTC-5, Constantin Konstantinidis wrote: > > I don't see clearly which OS you run on, but "../cli" should work if you > run locally. > > On Tuesday, October 9, 2018 at 6:49:20 PM UTC+2, D Whelp wrote: >> >> Hello all, >> >> Super new to Golang, loving the hell out of it, but I am running into a >> small issue. I have a small application that I am working through. I can >> import my models using `import ("/dojo/pkg/models")` in main.go just fine. >> Now I am trying to build a `cli` package and I cannot import it. Every >> time I do, I cannot use the function `QueryESXi()` that is in my esxi.go >> Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but >> none are working. What am I missing? Thanks in advance. >> >> >> -- 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] Re: Importing local package
Forgive my ignorance, I am working from MacOS but realized my mistake about 20 min after I had submitted the issue I was having. The import wasnt really the issue, it was my usage of the QueryESXi function. I was trying to call it directly but figured out after a few hours of frustration and googling that `cli.QueryESXi()` fixed my issue. Super noob mistake on my part. I apologize for wasting the communities time on something so trivial and appreciate the responses. Thanks! On Tuesday, October 9, 2018 at 1:21:38 PM UTC-5, Constantin Konstantinidis wrote: > > I don't see clearly which OS you run on, but "../cli" should work if you > run locally. > > On Tuesday, October 9, 2018 at 6:49:20 PM UTC+2, D Whelp wrote: >> >> Hello all, >> >> Super new to Golang, loving the hell out of it, but I am running into a >> small issue. I have a small application that I am working through. I can >> import my models using `import ("/dojo/pkg/models")` in main.go just fine. >> Now I am trying to build a `cli` package and I cannot import it. Every >> time I do, I cannot use the function `QueryESXi()` that is in my esxi.go >> Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but >> none are working. What am I missing? Thanks in advance. >> >> >> -- 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] Importing local package
Yes, my GOPATH and GOROOT are working fine in fact other local imports work as intended. I made a idiotic mistake and wasted so much time googling when I shouldve seen what I was doing wrong. I was calling `QueryESXi()` and adding the import line. I left off the `cli.QueryESXi()`. Once I did that importing `dojo/cmd/cli` worked like a champ. Thank you so much for reaching out! On Tuesday, October 9, 2018 at 1:23:22 PM UTC-5, Justin Israel wrote: > > > > On Wed, Oct 10, 2018, 5:49 AM D Whelp > > wrote: > >> Hello all, >> >> Super new to Golang, loving the hell out of it, but I am running into a >> small issue. I have a small application that I am working through. I can >> import my models using `import ("/dojo/pkg/models")` in main.go just fine. >> Now I am trying to build a `cli` package and I cannot import it. Every >> time I do, I cannot use the function `QueryESXi()` that is in my esxi.go >> Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but >> none are working. What am I missing? Thanks in advance. >> > > There is a bit of missing info here. Assuming you are using a GOPATH like > $GOPATH/src/dojo or you have a go.mod properly configured and are outside > your GOPATH, then an import like "dojo/cmd/cli" could work. I would > recommend sticking to absolute import paths and not using relative dot > imports. What is the package name in your esxi.go file? The fact that it is > in a cmd location implies that it would be a "main" package and thus not > intended to be imported by another package. > > >> >> -- >> 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] Re: Get dependency from enterprise repository
On Tuesday, October 9, 2018 at 11:28:05 AM UTC-7, Constantin Konstantinidis wrote: > > jFrog is my working environment. I remain puzzled by the %21 character in > the error message. Is it a typo or is it really included in the error > message ? Could you share the GOPROXY set up that you used ? > > Hi Konstantinidis, pprasanthi-MBP-A6F84:tests pprasanthi$ jfrog rt c show Server ID: http://stg-repo.org.com/artifactory Url: http://stg-repo.org.com/artifactory/ User: pprasanthi Password: *** Default: true So I build my dependencies and published in frog artifactory. So the module has all my deps. I unzip them and use it in my tests. Before I published the question as how to download dependencies from enterprise artifactory - I was downloading single deps from my module - which was not the correct way. So I was having issues. Now I download the entire module and which have my deps unzipped. Please let me know if you are also doing the same way? Thanks Pooja -- 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] Getting stack trace from panic before/on recover()
Wow, so it really was that easy... Thanks a lot. On Tuesday, October 9, 2018 at 11:04:24 PM UTC+3, Ian Lance Taylor wrote: > > On Tue, Oct 9, 2018 at 11:49 AM, jclc via golang-nuts > > wrote: > > I'm trying to make a graphical crash window on my program for my users > who > > will not have terminal access. I can panic with my own custom crash > dumps > > that include details that I can then handle after recover(), but I can't > get > > anything useful from a standard library panic. If the user tells me his > > program crashes with "nil pointer dereference" or "index out of range", > > that's not going to be very useful. I can't even redirect the stack > trace > > into a file by omitting recover(). If the runtime can print a stacktrace > > from where a panic occurred, is there really no way to get it and handle > it > > yourself? > > If you call recover, you can get a stack trace. The deferred function > that calls recover runs in the stack that calls panic. > > Ian > -- 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] Getting stack trace from panic before/on recover()
On Tue, Oct 9, 2018 at 11:49 AM, jclc via golang-nuts wrote: > I'm trying to make a graphical crash window on my program for my users who > will not have terminal access. I can panic with my own custom crash dumps > that include details that I can then handle after recover(), but I can't get > anything useful from a standard library panic. If the user tells me his > program crashes with "nil pointer dereference" or "index out of range", > that's not going to be very useful. I can't even redirect the stack trace > into a file by omitting recover(). If the runtime can print a stacktrace > from where a panic occurred, is there really no way to get it and handle it > yourself? If you call recover, you can get a stack trace. The deferred function that calls recover runs in the stack that calls panic. Ian -- 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] Robotgo v0.60.0 is released, Go desktop automation, refactoring window and example.
Golang Desktop Automation. Control the mouse, keyboard, bitmap, read the screen, Window Handle and global event listener. Robotgo v0.60.0 is released, refactoring window and example. https://github.com/go-vgo/robotgo/releases/tag/0.60.0 -- 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] Getting stack trace from panic before/on recover()
I'm trying to make a graphical crash window on my program for my users who will not have terminal access. I can panic with my own custom crash dumps that include details that I can then handle after recover(), but I can't get anything useful from a standard library panic. If the user tells me his program crashes with "nil pointer dereference" or "index out of range", that's not going to be very useful. I can't even redirect the stack trace into a file by omitting recover(). If the runtime can print a stacktrace from where a panic occurred, is there really no way to get it and handle it yourself? -- 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] Re: Get dependency from enterprise repository
jFrog is my working environment. I remain puzzled by the %21 character in the error message. Is it a typo or is it really included in the error message ? Could you share the GOPROXY set up that you used ? -- 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] Importing local package
On Wed, Oct 10, 2018, 5:49 AM D Whelp wrote: > Hello all, > > Super new to Golang, loving the hell out of it, but I am running into a > small issue. I have a small application that I am working through. I can > import my models using `import ("/dojo/pkg/models")` in main.go just fine. > Now I am trying to build a `cli` package and I cannot import it. Every > time I do, I cannot use the function `QueryESXi()` that is in my esxi.go > Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but > none are working. What am I missing? Thanks in advance. > There is a bit of missing info here. Assuming you are using a GOPATH like $GOPATH/src/dojo or you have a go.mod properly configured and are outside your GOPATH, then an import like "dojo/cmd/cli" could work. I would recommend sticking to absolute import paths and not using relative dot imports. What is the package name in your esxi.go file? The fact that it is in a cmd location implies that it would be a "main" package and thus not intended to be imported by another package. > > -- > 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. > -- 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] Re: Importing local package
I don't see clearly which OS you run on, but "../cli" should work if you run locally. On Tuesday, October 9, 2018 at 6:49:20 PM UTC+2, D Whelp wrote: > > Hello all, > > Super new to Golang, loving the hell out of it, but I am running into a > small issue. I have a small application that I am working through. I can > import my models using `import ("/dojo/pkg/models")` in main.go just fine. > Now I am trying to build a `cli` package and I cannot import it. Every > time I do, I cannot use the function `QueryESXi()` that is in my esxi.go > Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but > none are working. What am I missing? Thanks in advance. > > > -- 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] Importing local package
Hello all, Super new to Golang, loving the hell out of it, but I am running into a small issue. I have a small application that I am working through. I can import my models using `import ("/dojo/pkg/models")` in main.go just fine. Now I am trying to build a `cli` package and I cannot import it. Every time I do, I cannot use the function `QueryESXi()` that is in my esxi.go Attached is my layout. I have tried "./cmd/cli" and "dojo/cmd/cli"... but none are working. What am I missing? Thanks in advance. -- 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
That was awesome Gary pprasanthi-MBP-A6F84:gomodtry pprasanthi$ go mod download -json { "Path": "github.com/davecgh/go-spew", "Version": "v1.1.1", "Info": "/Users/pprasanthi/go/pkg/mod/cache/download/github.com/davecgh/go-spew/@v/v1.1.1.info", "GoMod": "/Users/pprasanthi/go/pkg/mod/cache/download/github.com/davecgh/go-spew/@v/v1.1.1.mod", "Zip": "/Users/pprasanthi/go/pkg/mod/cache/download/github.com/davecgh/go-spew/@v/v1.1.1.zip", "Dir": "/Users/pprasanthi/go/pkg/mod/github.com/davecgh/go-spew@v1.1.1", "Sum": "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", "GoModSum": "h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=" } Thank you. On Tuesday, October 9, 2018 at 1:03:14 AM UTC-7, gary.wi...@victoriaplumb.com wrote: > > You can also use the handy command `go mod download -json` to view > information about the dependencies and where they are on disk for a module. > > On Monday, 8 October 2018 22:29:46 UTC+1, ppras...@splunk.com wrote: >> >> 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] Re: Get dependency from enterprise repository
Thank you Vladimir Varankin , I dont want to use jfrog-cli. The problem I faced with jfrog-cli is - I can install jfrog-cli, and configure the artifactory using jfrog rt c and successfully go get dependencies to my test. But this approach works better on local machine. When I want to execute the tests in Docker image, I have issues configuring the proxy using jfrog cli command. On Tuesday, October 9, 2018 at 4:08:40 AM UTC-7, Vladimir Varankin wrote: > > Hey there! > > I don't know much about jfrog, but was curious to delve into the > enterprise proxies topic. It seems that you're supposed to use jfrog's own > jfrog-cli [1] to work with the artifactory. I believe the CLI simply set a > proper value to GOPROXY to URL, that supports gomod proxy protocol API [2]. > > Check if your artifactory responses with the list from " > http://stg-repo.com/api/go//@v/list". Note, "/api/go/" prefix is > seems what jfrog-cli uses [3]. > > [1]: https://www.jfrog.com/confluence/display/RTF/Go+Registry > [2]: https://tip.golang.org/cmd/go/#hdr-Module_proxy_protocol > [3]: > https://github.com/jfrog/jfrog-cli-go/blob/a664eede11e6988ca98f53e9541a3113e55112a8/jfrog-cli/artifactory/utils/golang/cmd.go#L52-L62 > > > On Monday, October 8, 2018 at 10:55:41 PM UTC+2, ppras...@splunk.com > wrote: >> >> 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.
Re: [go-nuts] Traverse directory without infinite loops while following symlinks
Well, I only have myself to blame for the complexity then. ;-) There is no visible difference, but there is an invisible one--the visitor functions are now potentially parallel so they must not access shared variables casually. One choice is to use a channel, one is to use mutual exclusion. On Tue, Oct 9, 2018 at 6:46 AM Robert Solomon wrote: > As the OP, I want to clarify my comment about grokking. I meant that it > takes time to understand someone else's code, not about CSP itself. > > I went through a YouTube series that writes a news aggregator in go using > CSP; it took 22 videos to explain the code. > > I started looking at Mike jones' code and I need to study it a bit more. > > -- > 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. > -- *Michael T. jonesmichael.jo...@gmail.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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: json: cannot unmarshal array into Go struct field data.Members of type main.Members
Rename your "slug string" to "Slug string" to make it public so the json package can write to it, and make the "Members" field of data a slice: type Member struct { Slug string } type data struct { Members []Member } On Tuesday, October 9, 2018 at 2:46:02 PM UTC+2, pdbw...@gmail.com wrote: > > > type Members struct { > slug string `json:"slug"` > } > type data struct { > Members Members //`json:"members"` > } > > func main() { > > resp, err := http.Get(" > https://gist.githubusercontent.com/DQIJAO/e14c64ea610688e70228a9fb8c649b2c/raw/6cccd444c1ef65411aa3662b112634996b837414/bnk48.json > ") > > defer resp.Body.Close() > > buf := new(bytes.Buffer) > buf.ReadFrom(resp.Body) > respByte := buf.Bytes() > var data data > > err = json.Unmarshal(respByte, ) > > if err != nil { > fmt.Println(err) > > return > } > > log.Println(data) > > } > -- 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] json: cannot unmarshal array into Go struct field data.Members of type main.Members
Members.slug is not exported. It should be Members.Slug, not Members.slug On Tue, Oct 9, 2018 at 6:45 AM wrote: > > > type Members struct { > slug string `json:"slug"` > } > type data struct { > Members Members //`json:"members"` > } > > func main() { > > resp, err := > http.Get("https://gist.githubusercontent.com/DQIJAO/e14c64ea610688e70228a9fb8c649b2c/raw/6cccd444c1ef65411aa3662b112634996b837414/bnk48.json;) > > defer resp.Body.Close() > > buf := new(bytes.Buffer) > buf.ReadFrom(resp.Body) > respByte := buf.Bytes() > var data data > > err = json.Unmarshal(respByte, ) > > if err != nil { > fmt.Println(err) > > return > } > > log.Println(data) > > } > > -- > 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. -- 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] json: cannot unmarshal array into Go struct field data.Members of type main.Members
type Members struct { slug string `json:"slug"` } type data struct { Members Members //`json:"members"` } func main() { resp, err := http.Get( "https://gist.githubusercontent.com/DQIJAO/e14c64ea610688e70228a9fb8c649b2c/raw/6cccd444c1ef65411aa3662b112634996b837414/bnk48.json; ) defer resp.Body.Close() buf := new(bytes.Buffer) buf.ReadFrom(resp.Body) respByte := buf.Bytes() var data data err = json.Unmarshal(respByte, ) if err != nil { fmt.Println(err) return } log.Println(data) } -- 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] Re: Get dependency from enterprise repository
Hey there! I don't know much about jfrog, but was curious to delve into the enterprise proxies topic. It seems that you're supposed to use jfrog's own jfrog-cli [1] to work with the artifactory. I believe the CLI simply set a proper value to GOPROXY to URL, that supports gomod proxy protocol API [2]. Check if your artifactory responses with the list from "http://stg-repo.com/api/go//@v/list". Note, "/api/go/" prefix is seems what jfrog-cli uses [3]. [1]: https://www.jfrog.com/confluence/display/RTF/Go+Registry [2]: https://tip.golang.org/cmd/go/#hdr-Module_proxy_protocol [3]: https://github.com/jfrog/jfrog-cli-go/blob/a664eede11e6988ca98f53e9541a3113e55112a8/jfrog-cli/artifactory/utils/golang/cmd.go#L52-L62 On Monday, October 8, 2018 at 10:55:41 PM UTC+2, ppras...@splunk.com wrote: > > 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.
Re: [go-nuts] [ANN] astiencoder: an open source video encoder written in GO and based on ffmpeg C bindings
Yeah sorry about the spam :( I forgot the link the first time and wanted to edit the title the second time. Didn't think there were notifications for every creation. Really sorry about that :( Le mardi 9 octobre 2018 10:47:33 UTC+2, Jan Mercl a écrit : > > On Tue, Oct 9, 2018 at 10:31 AM Asticode > > wrote: > > > I'm happy to announce go-astiencoder, an open source video encoder > written in GO and based on ffmpeg C bindings: > https://github.com/asticode/go-astiencoder > > Three separate announcements of the same thing in cca 20 minutes. > > -- > > -j > -- 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] [ANN] astiencoder: an open source video encoder written in GO and based on ffmpeg C bindings
On Tue, Oct 9, 2018 at 10:31 AM Asticode wrote: > I'm happy to announce go-astiencoder, an open source video encoder written in GO and based on ffmpeg C bindings: https://github.com/asticode/go-astiencoder Three separate announcements of the same thing in cca 20 minutes. -- -j -- 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] [ANN] astiencoder: an open source video encoder written in GO and based on ffmpeg C bindings
Hey guys, I'm happy to announce go-astiencoder, an open source video encoder written in GO and based on ffmpeg C bindings: https://github.com/asticode/go-astiencoder Its goal is to assemble the full audio/video encoding process in GO for people looking to: - understand how such a process work in detail - integrate their video encoder in a GO ecosystem - visualize their encoding workflow and statuses/stats of nodes in real time - communicate with their encoder through an HTTP API + websocket to tweak behaviours in real time - use native GO subtitle libraries like astisub - build their own video encoder and take control of its workflow Indeed resources to assemble such a thing in GO are scarce and I think the GO community could benefit from this project. Right now I've implemented basic examples of remux, thumbnail extraction and h264/aac encoding. I'm more than welcoming contributions. Cheers PS: the goal of this project is *NOT* to replace ffmpeg :D -- 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] [ANN] Open source video encoder written in GO and based on ffmpeg C bindings
Hey guys, I'm happy to announce go-astiencoder, an open source video encoder written in GO and based on ffmpeg C bindings: https://github.com/asticode/go-astiencoder Its goal is to assemble the full audio/video encoding process in GO for people looking to: - understand how such a process work in detail - integrate their video encoder in a GO ecosystem - visualize their encoding workflow and statuses/stats of nodes in real time - communicate with their encoder through an HTTP API + websocket to tweak behaviours in real time - use native GO subtitle libraries like astisub - build their own video encoder and take control of its workflow Indeed resources to assemble such a thing in GO are scarce and I think the GO community could benefit from this project. Right now I've implemented basic examples of remux, thumbnail extraction and h264/aac encoding. I'm more than welcoming contributions. Cheers PS: the goal of this project is *NOT* to replace ffmpeg :D -- 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] [ANN] Open source video encoder written in GO and based on ffmpeg C bindings
Hey guys, I'm happy to announce go-astiencoder, an open source video encoder written in GO and based on ffmpeg C bindings. Its goal is to assemble the full audio/video encoding process in GO for people looking to: - understand how such a process work in detail - integrate their video encoder in a GO ecosystem - visualize their encoding workflow and statuses/stats of nodes in real time - communicate with their encoder through an HTTP API + websocket to tweak behaviours in real time - use native GO subtitle libraries like astisub - build their own video encoder and take control of its workflow Indeed resources to assemble such a thing in GO are scarce and I think the GO community could benefit from this project. Right now I've implemented basic examples of remux, thumbnail extraction and h264/aac encoding. I'm more than welcoming contributions. Cheers PS: the goal of this project is *NOT* to replace ffmpeg :D -- 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] Re: Error Handling Best Practice (error wrapping)
Hi, There are two kinds of errors: user-facing error and developer-facing error. User-facing error is an error that is supposed to be relayed back to the end-users. It is usually stripped from sensitive information and is generally more verbose. On the other hand, developer-facing error are intended for developers. It may contain stacktraces, etc. and is generaly more terse. Go's standard error implementation is very basic and unassuming about your intended use. However, it is also trivial to write your own error library (Hint: the runtime package). I usually use my own error library. So whenever you find that the standard error implementation does not suit your need, feel free to implement your own. In addition, in designing your functions, be sure to return error judiciously. Consider whether returning errors provide any value to the callers of your functions, and whether it is sufficient to just return a neutral value or to panic. In general, functions that return errors are more difficult to use. It is easy to 'pass the buck' and just blindly send back any error to the caller. In the end, at the top layer of the application, you end up with way too many error checking code. So, return error judiciously. Some people think that using exceptions will help solve this problem. Exceptions merely hide the symptoms (eg. fewer error checking code), but it doesn't cure the problem, which is a poorly designed function interface. In fact, exceptions carry with them their own horde of problems. You have checked and unchecked exceptions. Some people prefer one to the other. Java has both, while the C# team considers checked exceptions does not bring any value to their existing problems. Then, you have versioning and scalability issue, etc. Go's error handling is not perfect, but it is simple and thus any associated problems surrounding it are also easy to understand. On Monday, October 8, 2018 at 5:38:09 PM UTC+7, Chris Hopkins wrote: > > Hi, > Could I please check what current error handling best practice is? > I've gotten quite smitten with github.com/pkg/errors. I really like the > ability to create a stack of errors that trace to what is going on. However > it seems this is not an often used package - it's not available in > playground for example. It's really useful for diagnostics to see a stack > of what is causing an error, however in my latest application where I'm > trying to be really rigorous with my error handling I've hit - for want of > a better word - an imperfection. Could I check if there's a better way to > do these things: > So here's what I'm doing: > When I have an error I need to report I create it like this: > var ErrInvalidVariable = errors.New("Invalid Variable") > Which means that you can have code that nicely reads: > if err == ErrInvalidVariable { /* handle this error */} > It's how the os package reports errors (along with helper functions), so I > assume this is the correct way. > > > For better debug I can use errors.Wrap to annotate this error through the > error stack and get useful diagnostic printouts such as > Line Processing passed "if $BOB==3": Token Passed $BOB : Invalid Variable. > > So far so good. This starts to fail though if I'm trying to determine lets > say a fileio error that came from the config file reader, vs the script > file reader. At the moment I can say > _, err := os.Open(...) > if err != nil { > return errors.Wrap(err, "Config File read error") > } > But without searching through the error text I can't tell who caused that. > Now I could declare a specific type for this, add a Cause handler onto > that, but it starts to get clunky to do that for every error condition. > Also it doesn't scale to more than 2 levels because it stops at the first > cause found. I can obviously work around this, but I'm thinking I'm doing > this wrong, a defining feature of go is the error handling - surely there's > a better way to do it than this!. > > Am I doing something unusual here and wanting to determine where in the > hierarchy of the stack a problem might have come from? How else do people > handle errors in situations like this, where you can't fully handle them > locally, so you want to return the error, but then when you get to the > higher levels you can handle them, as long as you have information about > the error. The annoying thing is, everything is there in the string of the > error message and I could strings.Contains my way through the error string > to work this out, but that feels a really stupid way to do this. > I also come across this in my test cases, I want to inject error to make > sure I am spotting errors correctly and checking that I am getting the > correct error from the correct place is really quite clunky at the moment, > if I could test that an error checker in location X was triggered by it > being passed an error that would save me a lot of code. > > Any suggestions gratefully
Re: [go-nuts] Where are the dependencies saved when we use go mod
You can also use the handy command `go mod download -json` to view information about the dependencies and where they are on disk for a module. On Monday, 8 October 2018 22:29:46 UTC+1, ppras...@splunk.com wrote: > > 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.