[go-nuts] Re: try to avoid additional memory allocations

2017-11-09 Thread peterGo
Vasiliy, For portability, when you initialize cfg.WorkDir, clean it: cfg.WorkDir = filepath.Clean(cfg.WorkDir) You can reduce the allocations from 5 to 1. However, optimization can lead to obscurity. For example, $ go test oid_test.go -bench=. BenchmarkVasiliy-4 200700 ns/op88

[go-nuts] Re: gRPC golang server and client testing

2017-11-09 Thread Zeewell Yu
Hi,any solution now? I am looking for the best way too. On Sunday, April 24, 2016 at 3:31:19 AM UTC+8, Sankar wrote: > > Hi > > I have a .proto file which I ran with protoc to generate the _pb.go file. > I then wrote a server and a client program that uses the above _pb.go > program. Now what i

[go-nuts] How to Upload a file using angular4 for browsing and api created in golang?

2017-11-09 Thread Mandeep Kaur
Hi, I am working on an application in which I need to upload a file using Golang and Angular 4.Suppose I have an input type file and an upload button on the screen. When I browse a file from my system and clicks upload button.Now following are my queries regarding file upload: 1. How will angu

Re: [go-nuts] interface{} as type []interface{}

2017-11-09 Thread Jesse McNelis
On Fri, Nov 10, 2017 at 10:27 AM, Trig wrote: > Is it possible to have an interface{} as type []interface{}? Yep, you can store a slice of interface{} in an interface{} eg. // interface{} holding an []interface{} holding ints var a interface{} = []interface{}{1,2,3,4,5} https://play.golang.org/

[go-nuts] Re: Problem designing APIs after the compress stdlib

2017-11-09 Thread Glen Huang
Any suggestion how to improve compressor and resizer's APIs? Regards, Glen On Thursday, November 9, 2017 at 12:26:14 PM UTC+8, Glen Huang wrote: > > I'm writing a small image processing tool, given an image content, it only > does two things: > > 1. compressing the image content > 2. generating

[go-nuts] Re: try to avoid additional memory allocations

2017-11-09 Thread krolaw
On Friday, 10 November 2017 13:52:51 UTC+13, krolaw wrote: > > func oid2filepath(cfg *Config, oID uint64) string { >return fmt.Sprintf("%s%c%x%c%016x", cfg.WorkDir, filepath.Separator, > oid2vid(oID), filepath.Separator, oID) > } > > On Friday, 10 November 2017 09:58:03 UTC+13, Vasiliy Tols

[go-nuts] Re: try to avoid additional memory allocations

2017-11-09 Thread krolaw
func oid2filepath(cfg *Config, oID uint64) string { return fmt.Sprintf("%s%c%x%c%016x", cfg.WorkDir, filepath.Seperator, oid2vid(oID), filepath.Seperator, oID) } On Friday, 10 November 2017 09:58:03 UTC+13, Vasiliy Tolstov wrote: > > Hi. I have server that read/write data to many files (each

[go-nuts] Re: Why is there a difference between floating-point multiplication with literals vs. variables in Go?

2017-11-09 Thread eriksrocks
Thanks for the answers. I wasn't interested as much in fixed decimal solutions as understanding why what appeared to be the same floating-point math on the surface was returning different results. I also posted this question on Stack Overflow and I think the answers there are pretty comprehensi

[go-nuts] Re: Why is there a difference between floating-point multiplication with literals vs. variables in Go?

2017-11-09 Thread Trig
There are 3rd-party packages/vendors that help with this, such as: https://github.com/shopspring/decimal On Thursday, November 9, 2017 at 5:36:03 PM UTC-6, Erik Swan wrote: > > Why are the following unequal in Go? Is this a bug, or is it by design? If > it's by design, why does this occur and is

Re: [go-nuts] Why is there a difference between floating-point multiplication with literals vs. variables in Go?

2017-11-09 Thread andrey mirtchovski
It's in the spec under constants: arithmetic has arbitrary precision. When you restrict to a floating point type by assigning to a variable you also restrict the precision of the result. On Thu, Nov 9, 2017, 4:35 PM wrote: > Why are the following unequal in Go? Is this a bug, or is it by design?

[go-nuts] Why is there a difference between floating-point multiplication with literals vs. variables in Go?

2017-11-09 Thread eriksrocks
Why are the following unequal in Go? Is this a bug, or is it by design? If it's by design, why does this occur and is this type of behavior documented anywhere? https://play.golang.org/p/itEV9zwV2a package main import ( "fmt" ) func main() { x := 10.1 fmt.Println("x == 10.1:

[go-nuts] interface{} as type []interface{}

2017-11-09 Thread Trig
Is it possible to have an interface{} as type []interface{}? -- 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 op

Re: [go-nuts] Re: Short Term DSN for database/sql

2017-11-09 Thread agruetz45
Makes sense. I think my question was more asking about the details of how the pool (sql.DB) worked. So this clears it up. The driver would provide the pool this connector to use vs the DNS string and that Connector could re-auth etc... This definitely allows for what I am looking for to be solv

Re: [go-nuts] Re: Short Term DSN for database/sql

2017-11-09 Thread Daniel Theophanes
I don't quite understand you question. It just allows drivers an alternate way for the pool (sql.DB) to open a connection. Nothing ever is "returned". On Thu, Nov 9, 2017 at 1:19 PM wrote: > What would happen if idle/closed connections that are in the SQL > interface's connection pool? They go b

Re: [go-nuts] Re: Short Term DSN for database/sql

2017-11-09 Thread agruetz45
What would happen if idle/closed connections that are in the SQL interface's connection pool? They go back to the driver provided Connector interface to re-authenticate/create a connection? Thanks, Anthony On Thursday, November 9, 2017 at 10:49:00 AM UTC-8, Daniel Theophanes wrote: > > It allow

[go-nuts] try to avoid additional memory allocations

2017-11-09 Thread Vasiliy Tolstov
Hi. I have server that read/write data to many files (each is about 4-32Mb). To determine on which file i need to read/write i'm use this function to os.OpenFile func oid2filepath(cfg *Config, oID uint64) string { file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x", oid2vid(oID)), fmt.Sprintf

Re: [go-nuts] Starting an HTTP server and logging about it

2017-11-09 Thread Caleb Spare
I always just go with (1). This problem occurs to me and always bugs me a little, but I file it under "issues the day is too short to worry about". In practice when you see this in the logs starting server on port 4567 it's clear enough what happened. On Thu, Nov 9, 2017 at 12:16 PM, Kevin Burk

[go-nuts] Starting an HTTP server and logging about it

2017-11-09 Thread Kevin Burke
I want to start an HTTP server, and then once it's started, log a message that the server has started. Here are the options for doing that: - log ahead of time. The message gets logged before the server starts listening on a socket, which means you might get the message and then an error l

RE: [go-nuts] question about GO and realtime GC interest by the user community

2017-11-09 Thread John Souvestre
I occasionally see projects which have hard real-time requirements, so I’m interested. I understand your concern with GC but you have looked at Go’s current GC? I don’t know if its limits (max pause time, max overhead) are “hard” but they are stated. The one which isn’t is latency due to s

[go-nuts] Re: Scaleway

2017-11-09 Thread Mauricio Rojas
Hi, 1.- Install Docker: apt-get install docker 2.- Search Golang image docker on Docker Hub: docker search golang 3.- Install image 4.- Run application... Or 1.- Download https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz

[go-nuts] Re: Scaleway

2017-11-09 Thread Mauricio Rojas
Hi, 1.- Install DockerToolbox 2.- Run command: docker build -t my-golang-app . Or 1.- Download https://redirector.gvt1.com/edgedl/go/go1.9.2.windows-amd64.zip 2.- Unzip go1.9.2.windows-amd64.zip 3.- Set environment variable GOPATH to workspace GO 4.- Set path /bin Regards El jueves, 9 de

[go-nuts] [ANN] Pocket Gophers’ Guide to JSON - Early Access Special

2017-11-09 Thread Nathan Kerr
The Pocket Gophers’ Guide to JSON Learn how to confidently handle *any* JSON with the Pocket Gophers’ Guide to JSON. You’ll learn a universal approach to deal with any JSON that leverages encoding/json and other JSON tools in the Go ecosystem along wit

Re: [go-nuts] Re: Short Term DSN for database/sql

2017-11-09 Thread Daniel Theophanes
It allows drivers a way to provide a connection to the pool on demand, without needing to go through a static connection string. On Thu, Nov 9, 2017 at 9:09 AM wrote: > So this would allow for the driver to support a different method of > opening the connection that the sql interface would use w

[go-nuts] Scaleway

2017-11-09 Thread tactician
Am running on Windows. How do I load Go 1.9 onto ubuntu -- 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

[go-nuts] Re: Short Term DSN for database/sql

2017-11-09 Thread agruetz45
So this would allow for the driver to support a different method of opening the connection that the sql interface would use when it needed to open a new connection correct? Anthony On Tuesday, November 7, 2017 at 9:44:05 AM UTC-8, Daniel Theophanes wrote: > > Go1.10 will ship with a driver conn

[go-nuts] question about GO and realtime GC interest by the user community

2017-11-09 Thread David Beberman
Hi, I asked this on the golang-dev list. They redirected me here. We are a hard realtime JavaVM GC company. By hard realtime we mean that the GC is preemptible, reentrant, non-blocking, non-pausing. For multicore it is also parallel and concurrent. Further for realtime we support priority inherit

Re: [go-nuts] Not getting correct results with sort.Slice().

2017-11-09 Thread mrojasb2000
Hi, sorted := sortSliceIsSorted(indexes, func(i, j int) bool { return rantings[indexes[i]] < rantings[indexes[j]] }) fmt.Println("Slice sorted?:", sorted) El jueves, 9 de noviembre de 2017, 9:36:47 (UTC-3), gaurav escribió: > > I realized the mistake :-p > It needs to be this: > > sort.Sli

[go-nuts] Re: Upcasting/Downcasting in Go

2017-11-09 Thread Mauricio Rojas
Hi All, (S(d)).testUnderlyingTypeReciever() Regards El miércoles, 8 de noviembre de 2017, 18:44:36 (UTC-3), Haiyu Zhen escribió: > > As someone who is new to Golang world, I am confused with the following > code. > > As sample code shown, type S's "underlying" type is slice (in C++ jargon S >

[go-nuts] Re: Opening a Chrome Extension (.crx) file

2017-11-09 Thread Luis Furquim
Thank you for the directions! But this was just the first bit of the problem... I changed locally the archive/zip sources, making it accept both magic sequences on fileHeaderSignature and directoryHeaderSignature. Then I ran in UnexpectedEOF trap! I think that there is some version/flavor of the

Re: [go-nuts] Golang performance benchmarks on arm64 (Qualcomm Centriq 2400)

2017-11-09 Thread Gerald Henriksen
On Wed, 8 Nov 2017 13:57:03 -0800 (PST), you wrote: >"Go support for aarch64 is quite disappointing. >Qualcomm and other ARMv8 >vendors intends to put significant engineering resources to amend this >situation, but really any one can contribute to Go. So if you want to live >your mark, now is

[go-nuts] Re: Opening a Chrome Extension (.crx) file

2017-11-09 Thread Tamás Gulácsi
2017. november 9., csütörtök 14:11:13 UTC+1 időpontban Luis Furquim a következőt írta: > > Hello Gophers! > > I am trying to open a chrome extension file to read its manifest.json. It > is a zip file with a .crx extension. When I unzip via command line it works > like a charm. But, if I try wit

[go-nuts] Opening a Chrome Extension (.crx) file

2017-11-09 Thread Luis Furquim
Hello Gophers! I am trying to open a chrome extension file to read its manifest.json. It is a zip file with a .crx extension. When I unzip via command line it works like a charm. But, if I try with golang using package archive/zip it gives me the "zip: not a valid zip file" error. It's not the fir

Re: [go-nuts] Not getting correct results with sort.Slice().

2017-11-09 Thread gaurav
I realized the mistake :-p It needs to be this: sort.Slice(indexes, func(i, j int) bool { return ratings[indexes[i]] < ratings[indexes[j]] }) On Thursday, November 9, 2017 at 6:02:29 PM UTC+5:30, gaurav wrote: > > Hi Jan, > > I am still unable to understand why is the contract broken? The >

Re: [go-nuts] Not getting correct results with sort.Slice().

2017-11-09 Thread Gaurav Agarwal
Hi Jan, I am still unable to understand why is the contract broken? The "magnitude" of each entry in "indexes" slice is defined by less func in a consistent way. What exactly am I doing incorrect here? If I changed the program to create structs type entry struct { rating int index int } And then

Re: [go-nuts] Not getting correct results with sort.Slice().

2017-11-09 Thread Jan Mercl
On Thu, Nov 9, 2017 at 1:17 PM gaurav wrote: > I must be missing something basic here: a simple usage of sort.Slice is not sorting the slice correctly for me. I must be missing something very basic here; could someone please check this out? The less test is perfomed on the ratings slice, but the

[go-nuts] Not getting correct results with sort.Slice().

2017-11-09 Thread gaurav
Hi All, I must be missing something basic here: a simple usage of sort.Slice is not sorting the slice correctly for me. I must be missing something very basic here; could someone please check this out? https://play.golang.org/p/AEMq_9ml1n package main import ( "fmt" "sort" ) func main() { rati

Re: [go-nuts] Upcasting/Downcasting in Go

2017-11-09 Thread Konstantin Khomoutov
On Wed, Nov 08, 2017 at 02:48:06PM -0800, Ian Lance Taylor wrote: [...] >> So when should I expect the type casting to work? [...] > When thinking about Go it's best to avoid concepts that do not apply, > like derived class, upcast, and downcast. You can't write > d.testUnderlyingTypeAsReceiver()

Re: [go-nuts] Writing your own Context, making sure it's compatible with context.Context

2017-11-09 Thread Albert Tedja
> Can you just have a field of your Context type be a value of type > context.Context? > > Ian > I managed to do this eventually. The confusion was that my library has multiple types of contexts and they need to be stacked in any particular order. So at first, the values from previous (pare

[go-nuts] Re: I want to add comment crypto/sha1

2017-11-09 Thread al14031
I see . Thank you for replying. By the way, is there somewhere you want the document to modify somewhere? I absolutely want to contribute to golang 2017年11月9日木曜日 15時23分15秒 UTC+9 Dave Cheney: > > You cannot add an example to an unexported type, because that type cannot > be constructed from outsi