[go-nuts] expected bahaviour for fmt.Stringer within a container in a struct?

2017-08-30 Thread Dan Kortschak
What is the expected behaviour for this code? https://play.golang.org/p/tp9YNQZRMo ``` package main import ( "fmt" ) type char int func (c char) String() string { return string(c) } type st struct { m map[int]interface{} } func main() { a := char('A') s := st{

[go-nuts] Building gopath packages

2017-08-30 Thread Tamás Gulácsi
See github.com/rjeczalik/gobin for updating, but a simple "go install $GOPATH/src/..." may be enough. -- 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

[go-nuts] Building gopath packages

2017-08-30 Thread Tharaneedharan Vilwanathan
Hi All, Is there a simple way to build/rebuild all the packages in gopath? Something like a single command? Thanks dharani -- 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

Re: [go-nuts] sanitize filename from post form upload

2017-08-30 Thread Tamás Gulácsi
Use if i := strings.LastIndexAny(fn, "/\\"); i >= 0 { fn = fn[i+1:] } As windows path uses different separator. -- 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 g

Re: [go-nuts] sanitize filename from post form upload

2017-08-30 Thread David Arroyo
To sanitize a file path you can use https://golang.org/pkg/path/#Clean , but you probably want to use https://golang.org/pkg/path/#Base . The reason is that depending on the browser/client, you may get a path containing slashes, or you may get just the base filename. So it's better to just extract

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Michael Jones
good point. I was trying to show that the buffered stdin was "just like" normal scanning but the performance was less compared to the updated scanning code. here is another version, this time with a data generator and since the input is line oriented, the default split function is fine. https://p

[go-nuts] Re: Golang 1.9 failing with excelize (simple case works under 1.8.3)

2017-08-30 Thread silviucapota
This library https://github.com/plandem/xlsx that was advertised here a few days ago worked for me with your initial test.xlsx On Wednesday, 30 August 2017 18:42:19 UTC-4, G Shields wrote: > > Tried the trick with saving under LibreOffice and MS excel, and in both > cases the files created are d

[go-nuts] newbie with go 1.9 troubles

2017-08-30 Thread Dave Cheney
I'd check a few things, 1. Uninstall any version of Go provided by your is, if it's Ubuntu, the package will be called golang-go. 2. Unset every environment variable save GOPATH. If you are following the installations from golang.org, you never need to set GOROOT. 3. Delete /usr/local/go and unp

Re: [go-nuts] newbie with go 1.9 troubles

2017-08-30 Thread Ian Lance Taylor
On Wed, Aug 30, 2017 at 3:33 PM, rob wrote: > > I d/l the tar.gz file and followed the instructions to install it to > /usr/local/go and set $PATH, $GOPATH, $GOBIN and $GOROOT. Don't set GOROOT. The file go/src/runtime/mstkbar.go was in 1.8 but does not exist in Go 1.9. If you expect to have Go

[go-nuts] newbie with go 1.9 troubles

2017-08-30 Thread rob
Ubuntu 16.04 amd64 I d/l the tar.gz file and followed the instructions to install it to /usr/local/go and set $PATH, $GOPATH, $GOBIN and $GOROOT. When I do go version, I get 1.9. But I cannot compile anything, not even hello.go The error is: # runtime /usr/local/go/src/runtime/mstkbar.go:

[go-nuts] Re: Golang 1.9 failing with excelize (simple case works under 1.8.3)

2017-08-30 Thread G Shields
Tried the trick with saving under LibreOffice and MS excel, and in both cases the files created are different and both continue to fail. At this point 1.9 is not stable for me with XML. Enclosed are some more files (renamed for the application origin, but the same test.xlsx) Thanks On Friday,

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Patrick Smith
That is simpler, but slower. Not nearly as slow as using unbuffered io though. Timings on my machine, reading 1e6 integers chosen randomly from the range [0,1e18): Original code https://play.golang.org/p/grB-muK7hw 5.626974435s 155.367779ms Original poster's optimized code https://play.golang.org

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Michael Jones
This can be much simpler... https://play.golang.org/p/tMyipz6sYU On Wed, Aug 30, 2017 at 7:55 AM, Nilsocket wrote: > > Can you provide example code for how you read the input? >> > > Both of them were given same input size is:100, (i.e., 1 million) > > https://play.golang.org/p/grB-muK7hw >

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Nilsocket
> Can you provide example code for how you read the input? > Both of them were given same input size is:100, (i.e., 1 million) https://play.golang.org/p/grB-muK7hw // Time taken to read input : 9.840256889s // Time taken to sort: 731.469604ms I have implemented the same using bufio: http

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Andrew
Sorry, Should be `` On Wednesday, August 30, 2017 at 8:21:05 AM UTC-7, Andrew wrote: > > Thanks all for your reply. > > I have a web page which client can upload images to Go server. My > intention is to limit each image file size to max 2M. But they can upload > multiple files at a time. > > Th

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Andrew
Thanks all for your reply. I have a web page which client can upload images to Go server. My intention is to limit each image file size to max 2M. But they can upload multiple files at a time. The sample can be found here: https://play.golang.org/p/0VV3s7klQu -- You received this message beca

[go-nuts] sanitize filename from post form upload

2017-08-30 Thread gocss
Is there go code to sanitize a filename [or filename(s) if ] when the handler is processing them so as to detect things such as ../ that might be buried within them ? Also is there a way to find out the full pathname? -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] english language help

2017-08-30 Thread Oleg Puchinin
ОНО Спасибо ! 2017-08-30 20:30 GMT+06:00 Konstantin Khomoutov : > On Wed, Aug 30, 2017 at 07:17:26PM +0600, Oleg Puchinin wrote: > > > Hello ! > > Anybody speak russian ? > > I work on "Jay" - indexer for Go language (for LiteIDE). Can anybody > speak > > my this theme in russian language ? > > >

Re: [go-nuts] english language help

2017-08-30 Thread Konstantin Khomoutov
On Wed, Aug 30, 2017 at 07:17:26PM +0600, Oleg Puchinin wrote: > Hello ! > Anybody speak russian ? > I work on "Jay" - indexer for Go language (for LiteIDE). Can anybody speak > my this theme in russian language ? > > Last link: > svn checkout --username=olegpuchinin svn+ssh:// > olegpuchi...@svn

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Ian Lance Taylor
On Wed, Aug 30, 2017 at 12:52 AM, wrote: > > I have seen that python input and output is buffered, but golang's input and > output is not buffered. > > For those types of problems where i need to take large amounts of input, > It's taking long time to just take input than to do processing. > When

[go-nuts] english language help

2017-08-30 Thread Oleg Puchinin
Hello ! Anybody speak russian ? I work on "Jay" - indexer for Go language (for LiteIDE). Can anybody speak my this theme in russian language ? Last link: svn checkout --username=olegpuchinin svn+ssh:// olegpuchi...@svn.code.sf.net/p/opjay/code/ opjay-code Thank you ! Oleg. -- You received this

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Lutz Horn
For those types of problems where i need to take large amounts of input, It's taking long time to just take input than to do processing. Can you provide example code for how you read the input? Lutz -- You received this message because you are subscribed to the Google Groups "golang-nuts" gro

[go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread nilsocket
I have seen that python input and output is buffered, but golang's input and output is not buffered. For those types of problems where i need to take large amounts of input, It's taking long time to just take input than to do processing. When we have advantages with buffered input and output, wh

[go-nuts] Re: what is 'string'

2017-08-30 Thread ojucie
I can see that site gives a gentle introduction to Go. In Go you can define methods for your types. If your type has a method named String the standard library can use that method to convert the contents of your object to a string representation. In this particular case string is the return typ

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Steven Hartland
Sorry I was unclear, you are right, my intention was to identify where standard form size limiting is done for multipart/form-data POST requests. There is also a limit placed on "application/x-www-form-urlencoded" for POST requests unless the request body is already limited by MaxBytesReader,

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Lutz Horn
Limiting is done by the form parse: https://golang.org/pkg/net/http/#Request.ParseMultipartForm No, this is not limiting: The whole request body is parsed and up to a total of maxMemory bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files. ParseMul

[go-nuts] Re: can list.List.Push* or Get return nil?

2017-08-30 Thread Egon
Note slices do not allocate on every append/reslice... if you preallocate the slice for all elements you can avoid the allocations. You can take a look at https://baptiste-wicht.com/posts/2012/12/cpp-benchmark-vector-list-deque.html -- vector is quite similar to slice. If you cannot prealloca

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Steven Hartland
Limiting is done by the form parse: https://golang.org/pkg/net/http/#Request.ParseMultipartForm On 29/08/2017 20:40, Andrew wrote: Go 1.9 has "The new |FileHeader.Size|  field describes the size of a file in a multipart message." Suppose

[go-nuts] Re: can list.List.Push* or Get return nil?

2017-08-30 Thread BeaT Adrian
I want to make some data structures that can handle millions of entries. I will dome some benchmarks, but in theory slices should be slower (all that allocating/reallocating arrays behind the scenes). I don't know the size of the structures and I only need the first/last element. On Tuesday, Au

Re: [go-nuts] Upload File Size Limit in Go 1.9

2017-08-30 Thread Lutz Horn
Am 29.08.2017 um 21:40 schrieb Andrew: Go 1.9 has "The new |FileHeader.Size| field describes the size of a file in a multipart message." Suppose I upload multiple files using *multiple*> Can I use FileHeader.Size to limit *each* upload