Re: [go-nuts] Re: how do I make my function always run at exit in `go test`?

2019-01-09 Thread Justin Israel
Oh, I see. Well also adding a signal handler for SIGINT/SIGTERM also works for me: https://play.golang.org/p/93VmTTgE4YB Justin On Thu, Jan 10, 2019 at 6:29 PM 김용빈 wrote: > Sorry I didn't clarify but I mean when it is killed/terminated. > > 2019년 1월 10일 목요일 오후 2시 24분 35초 UTC+9, 김용빈 님의 말: > >>

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Jan Mercl
On Thu, Jan 10, 2019 at 6:30 AM Justin Israel wrote: > On Thu, Jan 10, 2019 at 6:04 PM 김용빈 wrote: > >> package main >> >> func unused(x interface{}) {} >> >> func main() { >> a := 1 >> unused(a) >> } >> > > The function isn't even required here. Assigning to underscore will > prevent the

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Justin Israel
On Thu, Jan 10, 2019 at 6:04 PM 김용빈 wrote: > package main > > func unused(x interface{}) {} > > func main() { > a := 1 > unused(a) > } > The function isn't even required here. Assigning to underscore will prevent the error: func main() { a := 1 _ = a } > > 2012년 3월 7일 수요일 오후 8

[go-nuts] Re: how do I make my function always run at exit in `go test`?

2019-01-09 Thread 김용빈
Sorry I didn't clarify but I mean when it is killed/terminated. 2019년 1월 10일 목요일 오후 2시 24분 35초 UTC+9, 김용빈 님의 말: > > I tried signal.Notify but it seems it doesn't work. > > Then I find this: > https://github.com/golang/go/issues/15553#issuecomment-217162874 > > So what should I do to make my funct

Re: [go-nuts] how do I make my function always run at exit in `go test`?

2019-01-09 Thread Justin Israel
On Thu, Jan 10, 2019 at 6:24 PM 김용빈 wrote: > I tried signal.Notify but it seems it doesn't work. > > Then I find this: > https://github.com/golang/go/issues/15553#issuecomment-217162874 > > So what should I do to make my function always run at exit in test? > A custom TestMain() is a good way to

[go-nuts] how do I make my function always run at exit in `go test`?

2019-01-09 Thread 김용빈
I tried signal.Notify but it seems it doesn't work. Then I find this: https://github.com/golang/go/issues/15553#issuecomment-217162874 So what should I do to make my function always run at exit in test? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread 김용빈
package main func unused(x interface{}) {} func main() { a := 1 unused(a) } 2012년 3월 7일 수요일 오후 8시 32분 19초 UTC+9, Elazar Leibovich 님의 말: > > I sometimes have a very strange error, which I can't understand its source. > > One of my techniques for finding it, is isolate the problem to a ver

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread robert engels
I’m pretty sure that is rose colored glasses… It is a pain, but at the same time, the lack of dynamic code modification is more of a pain, coupled with no private methods in file scope (because with those you could decompose the larger functions without polluting the namespace). But in many way

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Ekow
It is a good kind of pain. This intentional construct forces you to only use what you need at the point where you actually need it. YAGNI. Regards, B Charles Jnr. > On Jan 9, 2019, at 8:17 PM, Rich wrote: > > Yes at times it's a pain, after programming for a while in Go you just get > use

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Rich
Yes at times it's a pain, after programming for a while in Go you just get used to it, and I seldom run into an unused variable. Use Visual Studio Code, you'll get a red squiggly line and an error long before you ever try to compile the code. If you really want to keep the variable, variable=_

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Glen Newton
I use the "if false{..." extensively as described above. -- 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 option

Re: [go-nuts] Code coverage for a project

2019-01-09 Thread alex . besogonov
I actually have a similar request. I have an application that I want to test with integration tests and right now there's no real way to get coverage except by running everything using a unit test launcher. On Wednesday, January 9, 2019 at 6:22:23 AM UTC-8, Ian Lance Taylor wrote: > > On Tue, Ja

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Ian Lance Taylor
On Wed, Jan 9, 2019 at 1:46 PM wrote: > > So, 2019 year. Still no compiler flag. Slphers :) This isn't a matter of being slow, it's an intentional decision. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

[go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread xenginex
So, 2019 year. Still no compiler flag. Slphers :) среда, 7 марта 2012 г., 14:32:19 UTC+3 пользователь Elazar Leibovich написал: > > I sometimes have a very strange error, which I can't understand its source. > > One of my techniques for finding it, is isolate the problem to a very > small ca

Re: [go-nuts] Can I say that a pointer is a memory address where a variable is?

2019-01-09 Thread robert engels
I think this show move to r/programming > On Jan 9, 2019, at 12:55 PM, Justin Israel wrote: > > > > On Thu, Jan 10, 2019, 7:53 AM Justin Israel > wrote: > > > On Thu, Jan 10, 2019, 7:43 AM 伊藤和也 > wrote: > Can I say that a poi

Re: [go-nuts] Can I say that a pointer is a memory address where a variable is?

2019-01-09 Thread Justin Israel
On Thu, Jan 10, 2019, 7:53 AM Justin Israel wrote: > > > On Thu, Jan 10, 2019, 7:43 AM 伊藤和也 wrote: > >> Can I say that a pointer is a memory address where a variable is? >> > > A pointer is a memory address to a value (data in memory). > > A "variable" is just a name/label to *something*. That s

Re: [go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-09 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Jan 9, 2019 at 10:07 AM Eric S. Raymond wrote: > > Reasonable people can disagree, but I favor rewriting over > > transpilation, for draining that swamp. > > The problem is that in general nobody *does* rewrite old > infrastructure code. It tends to work just well enough to fester in > p

Re: [go-nuts] Can I say that a pointer is a memory address where a variable is?

2019-01-09 Thread Justin Israel
On Thu, Jan 10, 2019, 7:43 AM 伊藤和也 wrote: > Can I say that a pointer is a memory address where a variable is? > A pointer is a memory address to a value (data in memory). A "variable" is just a name/label to *something*. That something could be a pointer or it could be a value. That is, you can

[go-nuts] Re: Get data from url insert to mongo but can't insert json array

2019-01-09 Thread pdbw58107
expect result: [ { "contentData":"1 \u0e21\u0e01\u0e23\u0e32\u0e04\u0e21 ", "historyData":" \u0e27\u0e31\u0e19\u0e02\u0e36\u0e49\u0e19\u0e1b\u0e35\u0e43\u0e2b\u0e21\u0e48\u00a0 \u0e27\u0e31\u0e19\u0e2b\u0e22\u0e38\u0e14\u0e23\u0e32\u0e0a\u0e01\u0e32\u0e23", "id":1 }, {"contentData":"\u0

[go-nuts] Can I say that a pointer is a memory address where a variable is?

2019-01-09 Thread 伊藤和也
Can I say that a pointer is a memory address where a variable is? -- 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 mo

[go-nuts] Get data from url insert to mongo but can't insert json array

2019-01-09 Thread pdbw58107
package main import ( "log" "net/http" "time" "github.com/PuerkitoBio/goquery" "gopkg.in/mgo.v2" //"gopkg.in/mgo.v2" ) type Data struct { Name string `json:"name" bson:"name"` Away string `json:"away" bson:"away"` Pop int `json:"pop" bson:"pop"` CreatedAt time.Time `bson:"created

[go-nuts] Re: Wuffs: a new, memory-safe programming language

2019-01-09 Thread Eric S. Raymond
Nigel Tao : > Spun out of the "C++ 11 to Golang convertor" thread... > > > On Mon, Jan 7, 2019 at 12:27 AM Eric S. Raymond wrote: > > Perry and I have two different target languages in mind. Perry's > > target language is basically a repaired C - type-safe, almost > > upward-compatible. He and

Re: [go-nuts] Can I say that a pointer is a reference or memory address to a value?

2019-01-09 Thread Ian Denhardt
Possibly it's misleading if you're coming from C++ -- but if that's the case you probably already know what pointers are. It's compatible with how I've heard the term "reference" used in every other context. The fact that they are first class values is an important point, however. -Ian Quoting Wa

Re: [go-nuts] Can I say that a pointer is a reference or memory address to a value?

2019-01-09 Thread Wagner Riffel
i think the term reference is misleading, pointers holds a memory address, but they are variables, have their own space in memory. var i int var p1, p2 = &i, &i fmt.Printf("%p, %p, %p", &i, &p1, &p2) // 0x1000, 0x1004, 0x1008 while in c++ references variables for example, address are s

Re: [go-nuts] Can I say that a pointer is a reference or memory address to a value?

2019-01-09 Thread Ian Lance Taylor
On Tue, Jan 8, 2019 at 9:46 PM 伊藤和也 wrote: > > Can I say that a pointer is a reference or memory address to a value? Sure. 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, se

[go-nuts] Re: How to insert to mongodb in json{[]}

2019-01-09 Thread pdbw58107
I don't know get Title insert to mongo if it is solution your Full code : package main import ( "fmt" "log" "net/http" "gopkg.in/mgo.v2" "github.com/PuerkitoBio/goquery" "time" ) type Data struct{ Name string ` bson:"name"` Away string ` bson:"away"` CreatedAt time.Time `bson:"createdAt"` } fun

Re: [go-nuts] Code coverage for a project

2019-01-09 Thread Ian Lance Taylor
On Tue, Jan 8, 2019 at 11:52 PM wrote: > > I have creates all my test files in a separate single folder. Is it possible > to get code coverage as the source files are in different location not with > test files. > I am getting code coverage report with coverprofile when test files and > source

[go-nuts] Re: How to insert to mongodb in json{[]}

2019-01-09 Thread Mahendra Bhoir
Hi, This code works for me. You need to pass referance instead of actual variable. //here mongo is my package where function MongoConnect() creates a globle session and returns clone of session. func addTempCategory(category MainCategory) { mongoSession = mongo.MongoConnect() defer mongo

[go-nuts] How to insert to mongodb in json{[]}

2019-01-09 Thread pdbw58107
My code: session.SetMode(mgo.Monotonic, true) d:= session.DB("api").C("api") doc := Data{ Name: title, Away: band, } err = d.Insert(doc) json to expect [ { "contentData": "", "historyData": " ", }, { }, ] -- You received this message because you are subscrib

[go-nuts] Re: Patch method

2019-01-09 Thread Amnon Baron Cohen
try https://golang.org/pkg/net/http/ and https://golang.org/pkg/encoding/json/ On Tuesday, 8 January 2019 14:24:37 UTC, afriyie...@gmail.com wrote: > > Hi, > > Am new in Go programming and need help to write a PATCH method for my > go-server. > my data field look like these > > type NFProfile st

Re: [go-nuts] Web Scraping.result not show that expect result are Stone Age ,Roman Britain

2019-01-09 Thread Wojciech S. Czarnecki
On Wed, 9 Jan 2019 00:50:04 -0800 (PST) pdbw58...@gmail.com wrote: > I want to get data from html https://godoc.org/golang.org/x/net/html https://schier.co/blog/2015/04/26/a-simple-web-scraper-in-go.html > insert to database https://flaviocopes.com/golang-sql-database/ Hope this helps. -- Wojc

Re: [go-nuts] Web Scraping.result not show that expect result are Stone Age ,Roman Britain

2019-01-09 Thread pdbw58107
I want to get data from html insert to database for data to want are stone cold Contents https://en.wikipedia.org/wiki/History_of_England#Prehistory>">1 Prehistory https://en.wikipedia.org/wiki/History_of_England#Stone_Age>">1.1 Stone Age https://en.wikipedia.org/wiki/History_of_England#Later_P

Re: [go-nuts] Web Scraping.result not show that expect result are Stone Age ,Roman Britain

2019-01-09 Thread Wojciech S. Czarnecki
On Tue, 8 Jan 2019 21:05:00 -0800 (PST) pdbw58...@gmail.com attached a screenshot: https://www.google.com/search?q=how+to+copy+and+paste+text > [image: Screen Shot 2019-01-09 at 12.03.04 PM.png] -- Wojciech S. Czarnecki << ^oo^ >> OHIR-RIPE -- You received this message because you are subscr