[go-nuts] Re: Why does these two code behave differently? (swap two elements in a slice)

2017-03-22 Thread peterGo
Cholerae Hu, The assignment proceeds in two phases. First, the operands of index expressions and pointer indirections (including implicit pointer indirections in selectors

[go-nuts] Re: Why does these two code behave differently? (swap two elements in a slice)

2017-03-22 Thread Cholerae Hu
I test it on golang play. https://play.golang.org/p/trTGZsW6Ai https://play.golang.org/p/NEAavwidJ1 在 2017年3月23日星期四 UTC+8下午1:04:00,Cholerae Hu写道: > > First code: > package main > import ( > "fmt" > ) > > > func main() { > test := []int{2, 1, 1} > fmt.Println(findDuplicate(te

[go-nuts] Why does these two code behave differently? (swap two elements in a slice)

2017-03-22 Thread Cholerae Hu
First code: package main import ( "fmt" ) func main() { test := []int{2, 1, 1} fmt.Println(findDuplicate(test)) } func findDuplicate(nums []int) int { for i := 0; i < len(nums); i++ { if nums[i] != i+1 { if nums[i] == nums[nums[i]-1] {

[go-nuts] [ANNOUNCE] gomacro - a Go interpreter with Eval and Lisp-like macros

2017-03-22 Thread massimiliano . ghilardi
Hi everyone, I am happy to announce gomacro, yet another Go interpreter: https://github.com/cosmos72/gomacro I started it as an experiment to play with Go, and to try adding Lisp-like macros, i.e. compile-time execution of arbitrary user code (extremely handy for code generation). It turned i

Re: [go-nuts] Re: plugins (Go 1.8) and packages

2017-03-22 Thread Ian Lance Taylor
On Wed, Mar 22, 2017 at 3:06 AM, Basile Starynkevitch wrote: > > First, is Svetlin's golang-sharing-libraries tutorial still exactly correct > for Go1.8 specifically? Its title Sharing Golang packages to C and Go is a > bit misleading. I just want all my non-main packages to be "shared objects" >

[go-nuts] [ANN] cascadia, the command line tool

2017-03-22 Thread Tong Sun
Hi, I've just turned my cascadia from a thin wrapper around the Go Cascadia package , into a poor man's scrapper tool. Please check it out at https://github.com/suntong/cascadia Here are some exception: The Go Cascadia package

Re: [go-nuts] Is Go a server side language or a client side?

2017-03-22 Thread Wim Lewis
On Mar 22, 2017, at 11:10 AM, Marlon Fez wrote: > I just heard about go, a new good language, but I cannot find the answer to > my question. Is this new programming language a server side (Back-End) > language or a client side (Front-End) language? > I currently work with C# for server side wor

[go-nuts] Is Go a server side language or a client side?

2017-03-22 Thread Marlon Fez
Hello, I just heard about go, a new good language, but I cannot find the answer to my question. Is this new programming language a server side (Back-End) language or a client side (Front-End) language? I currently work with C# for server side work and JavaScript for client side. Is Golang work i

[go-nuts] Re: x509.ParseECPrivateKey cannot parse ECDSA (256-bit curve) keys generated using openssl ecparams

2017-03-22 Thread adam . woodbeck
Hi Megha, Generate the key in DER format instead of PEM. openssl ecparam -genkey -name secp384r1 -outform der -noout -out key.der You can then read in the file using ioutil.ReadFile() for instance, and pass the byte slice to x509.ParseECPrivateKey(). Adam On Tuesday, April 26, 2016 at 5:07:15

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Jesper Louis Andersen
It isn't just inlining that affects closures. Most programming languages with closures use several closure representations at the same time. The compiler picks among them depending on which representation gives the best program efficiency at runtime and depending on what information they staticall

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 10:38:32 PM UTC+8, T L wrote: > > > > On Wednesday, March 22, 2017 at 7:49:39 PM UTC+8, Dave Cheney wrote: >> >> Well, that program isn't that simple because of the closure, but also >> because it contains a data race >> >> Something like this is easier to reason

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 7:49:39 PM UTC+8, Dave Cheney wrote: > > Well, that program isn't that simple because of the closure, but also > because it contains a data race > > Something like this is easier to reason about > > var x *int > > func main() { > var a int > x = &a

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 9:29:32 PM UTC+8, Ian Lance Taylor wrote: > > On Wed, Mar 22, 2017 at 3:59 AM, T L > > wrote: > > > > On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > >> > >> On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: > >> > > >> > More accurately

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Ian Lance Taylor
On Wed, Mar 22, 2017 at 3:59 AM, T L wrote: > > On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: >> >> On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: >> > >> > More accurately, I think it should be: from the POV of a programmer, >> > it's >> > globals, and things reachable fro

[go-nuts] Re: Golang http reverse proxy in production

2017-03-22 Thread ironsmile
I've used a reverse proxy, written in Go in production. It did perform as good and even slightly better than nginx for our use case. It was regularly keeping 10GBps LAN cards full to the brim without much sweat. Our use case was serving and caching constantly changing library of huge media files

[go-nuts] go program memleak

2017-03-22 Thread cellterry
Dear all, I had written a go program but I found that it has 100k memory leak per day. I have tried to use pprof to check but it does not show anything: curl -s http://localhost:6060/debug/pprof/heap > ~/Downloads/base.heap : : one hour later : : curl -s http://localhost:6060/debug/pprof/heap

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
Well, that program isn't that simple because of the closure, but also because it contains a data race Something like this is easier to reason about var x *int func main() { var a int x = &a fmt.Println(*x) } On Wednesday, 22 March 2017 21:59:17 UTC+11, T L wrote: > > >

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > > On Wed, Mar 22, 2017 at 8:51 PM, T L > > wrote: > > > > More accurately, I think it should be: from the POV of a programmer, > it's > > globals, and things reachable from each goroutine. > > > > The only way to rea

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > > On Wed, Mar 22, 2017 at 8:51 PM, T L > > wrote: > > > > More accurately, I think it should be: from the POV of a programmer, > it's > > globals, and things reachable from each goroutine. > > > > The only way to rea

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Jesse McNelis
On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: > > More accurately, I think it should be: from the POV of a programmer, it's > globals, and things reachable from each goroutine. > The only way to reach a value is through a variable in scope and the only variables in scope are global or on the stack

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread tpoisonooo
Well, size of all my face data is 222MB, not 716612. -- 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, v

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:00:12 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 20:51:18 UTC+11, T L wrote: >> >> >> >> On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: >>> >>> The comment on >>> >>> https://github.com/golang/go/blob/master/src/runtim

[go-nuts] Re: plugins (Go 1.8) and packages

2017-03-22 Thread Basile Starynkevitch
On Tuesday, March 21, 2017 at 5:59:11 PM UTC+1, Ian Lance Taylor wrote: Well, there are no Go plugin gurus, and to be honest I'm starting to > think it was a mistake to let the plugin package into 1.8. I know > that is not what you want to hear. It's in because the API seems OK, > but it ha

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 20:51:18 UTC+11, T L wrote: > > > > On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: >> >> The comment on >> >> https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 >> >> //c. GC performs root marking jobs. This includes scanning all

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread Dave Cheney
716612 / 4092340 is ~ 17.5% On Wednesday, 22 March 2017 20:49:25 UTC+11, tpoisonooo wrote: > > Thanks @Dave Cheney, I add 512MB `swap`, now Ubuntu would not kill Go > application. > But I still don't understand why `top` shows 17.5% memory usage. > -- You received this message because you ar

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: > > The comment on > > https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 > > //c. GC performs root marking jobs. This includes scanning all > //stacks, shading all globals, and shading any heap pointers in

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread tpoisonooo
Thanks @Dave Cheney, I add 512MB `swap`, now Ubuntu would not kill Go application. But I still don't understand why `top` shows 17.5% memory usage. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivi

[go-nuts] Re: [ANN] atomic operations as methods on types

2017-03-22 Thread 'Ingo Oeser' via golang-nuts
Thx for the valuable feedback! I just added a bugs section to the package doc so it's transparent, that the same limitations (and workarounds) apply as in the sync/atomic package. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
The comment on https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 //c. GC performs root marking jobs. This includes scanning all //stacks, shading all globals, and shading any heap pointers in //off-heap runtime data structures. Scanning a stack stops a //goroutine,

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:33:21 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 19:29:02 UTC+11, T L wrote: >> >> >> >> On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: >>> >>> >>> >>> On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: I

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread Dave Cheney
It looks like the vm you're running in has no swap configured. It's usually a good idea to add a small amount of swap, even if it is never used, it will make the linux vmm system less paranoid about running out of memory. If that isn't an option you need to alter the overcommit options to let th

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread tpoisonooo
I know that `top` is not report accurate memory usage. Now that Go application only use 222MB memory, why `top` shows 17.5% memory usage? >From Ubuntu 's point of view, my application uses too much memory. I think it is the reason why ubuntu would kill my process. -- You received this message

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 19:29:02 UTC+11, T L wrote: > > > > On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: >> >> >> >> On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: >>> >>> In this article: https://blog.golang.org/go15gc , it mentions >>> >>> ..., The GC visits

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: >> >> In this article: https://blog.golang.org/go15gc , it mentions >> >> ..., The GC visits all *roots*, which are objects directly accessible by >>> the applicat

[go-nuts] Re: go1.6: memory usage too high

2017-03-22 Thread Dave Cheney
Top is not reporting the accurate memory usage of your application. There are several ways to introspect your Go application to find its real memory usage, but the easiest way is to set GODEBUG=gctrace=1 and wait for lines that start with scvg: to be printed, they will tell you the current memo

[go-nuts] go1.6: memory usage too high

2017-03-22 Thread tpoisonooo
I have nearly implemented a face recognition server on my nvdia tx1. It loads all face data from MYSQL, listen port, receive picture and return the nearest face's name. I use `top` to show how many memory this program used, like this; >top - 07:46:03 up 2 days, 5:55, 3 users, load average:

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: > > In this article: https://blog.golang.org/go15gc , it mentions > > ..., The GC visits all *roots*, which are objects directly accessible by >> the application such as globals and things on the stack, and colors these >> grey. ... > > >

[go-nuts] one GC implementation question

2017-03-22 Thread T L
In this article: https://blog.golang.org/go15gc , it mentions ..., The GC visits all *roots*, which are objects directly accessible by > the application such as globals and things on the stack, and colors these > grey. ... It lists two kinds of root objects: globals and objects on stacks. My q

[go-nuts] Re: [ANN] atomic operations as methods on types

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 8:20:01 AM UTC+8, Ingo Oeser wrote: > > Hi all, > > I wrote a small package which implements atomic operations on types. > This is more comfortable to use and enabled building an atomic boolean > type (which has been the motivation) here. > > Documentation at htt

[go-nuts] Re: const type deduction

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 9:23:04 AM UTC+8, WinD zz wrote: > > > func main() { > const abc = 111 > fmt.Printf("%t\n", abc) > fmt.Println(math.Pi * abc) > fmt.Printf("%t", math.Pi) > } > > result: > %!t(int=111) > 25.132741228718345 > %!t(float64=3.141592653589793) >

[go-nuts] Re: const type deduction

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 9:23:04 AM UTC+8, WinD zz wrote: > > > func main() { > const abc = 111 > fmt.Printf("%t\n", abc) > fmt.Println(math.Pi * abc) > fmt.Printf("%t", math.Pi) > } > > result: > %!t(int=111) > 25.132741228718345 > %!t(float64=3.141592653589793) >

[go-nuts] Re: Golang http reverse proxy in production

2017-03-22 Thread lee
Strangely we just tried deploying a really simple one but with large-ish POST payloads. For some reason the number of requests/s would never match what would hit the nginx servers directly without the Go proxy. wrk & ab profiles were able to cope but as soon as any real world traffic hit the

[go-nuts] Any idea on call c function in runtime package in arm64?

2017-03-22 Thread bronze man
I am tring to write something like following in runtime package: /usr/local/go/src/runtime/write_err_ios.go ``` // +build ios // +build arm arm64 package runtime import "unsafe" var ( gWriteBuf [1024]byte gWritePos int ) //go:nosplit func asmAslLogWrap(b unsafe.Pointer) func writeErr(b []byte