Re: [go-nuts] look for a example: call a DLL's function on Windows by CGO

2017-08-03 Thread Konstantin Khomoutov
Hi! Unfortunately you forgot to use the "reply to all" or "reply to list" action so the message has only been sent to me, not to the list. Please re-send/re-post correctly. On Thu, Aug 03, 2017 at 07:33:03PM +0800, Fino Meng wrote: >>> yesterday I just found that, the syscall way to use DLL on

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Konstantin Khomoutov
On Thu, Aug 03, 2017 at 07:21:24AM +, Henrik Johansson wrote: [...] > It gets hypothetical pretty quick and usually when this happens I make sure > to create a new array/slice/whatever and then atomically swap it before > some other goroutine uses it but I generally avoid indexing assignment

Re: [go-nuts] look for a example: call a DLL's function on Windows by CGO

2017-08-03 Thread Konstantin Khomoutov
On Wed, Aug 02, 2017 at 08:33:53PM -0700, Fino wrote: > yesterday I just found that, the syscall way to use DLL on Windows cannot > use float32 as parameters, Could you please elaborate on that as I do not beleive this is not possible: IIRC Go's float types follow IEEE 754 semantics and you

Re: [go-nuts] Socket Priority affect Read Deadline?

2017-08-02 Thread Konstantin Khomoutov
On Wed, Aug 02, 2017 at 05:41:15AM -0700, jlu@gmail.com wrote: > I wrapped some code to do listen UDP port and set priority, like this > > func ListenUDP(t string, laddr *net.UDPAddr, priority int) (*net.UDPConn, > error) { > conn, err := net.ListenUDP(t, laddr) [...] > err =

[go-nuts] Background reader in an HTTP server's connection serving loop

2017-08-02 Thread Konstantin Khomoutov
The "conn" type from net/http/server.go, in its serve() method contains a "for" loop which is supposed -- as I understand it -- to keep reading requests from the connected socket if the client wished to reuse the connection. That loop reads the request's header and then starts a background

Re: [go-nuts] xml namespaces - encoding ok, decoding result not ok

2017-08-02 Thread Konstantin Khomoutov
On Tue, Aug 01, 2017 at 10:48:23AM -0700, Marcin Jurczuk wrote: > Your example is returning xml that is wrong from system I'm talking to. > My SOAP service requires tags in few different namespaces. > My code returns: > > * * > > Your code returns: > > ** [...] > > >

Re: [go-nuts] Re: "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-02 Thread Konstantin Khomoutov
On Tue, Aug 01, 2017 at 05:54:28AM -0700, kultigin@gmail.com wrote: > i believe you should avoid fallthrough statement except for auto-generated > code. > > it's obscure what you are trying to accomplish with that piece of code, but > surely you can do it in a better way. They have its

Re: [go-nuts] Re: GO Vs D

2017-08-01 Thread Konstantin Khomoutov
On Tue, Aug 01, 2017 at 05:04:24AM -0700, ecstatic.co...@gmail.com wrote: [...] > Go, as a web-centric language, has [...] Mildly put, this is a bold but unfounded statement. Web development is indeed booming, but it's booming on most contemporary programming languages -- be them PHP, Python,

Re: [go-nuts] Re: Reasoning behind behavior of range, when index is maintained

2017-07-27 Thread Konstantin Khomoutov
On Wed, Jul 26, 2017 at 08:44:46AM -0700, Christoph Berger wrote: > > someone shared [this question]( > > https://www.reddit.com/r/golang/comments/6paqc0/bug_that_caught_me_with_range/) > > > > on reddit. I must say, that I'm surprised by the behavior myself. I would > > have expected > > for

Re: [go-nuts] no.something seem like impossible,but it happens!!!!【 string 】causes the crash !!!!!!!!!!!!!!

2017-07-26 Thread Konstantin Khomoutov
On Wed, Jul 26, 2017 at 02:46:08AM -0700, 370265...@qq.com wrote: > > I think I can see at least one data race in your code. Try to run it using > > the race detector to verify. > thanks.yes,i thought this before too,but string is basic type of golang,to > read and write the same variable of

Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-26 Thread Konstantin Khomoutov
On Wed, Jul 26, 2017 at 02:52:05PM +0800, jesse junsay wrote: > > Check out github.com/tgulacsi/agostle - it walks the tree of mime parts > > of mail and converts everything to PDF, but you need the walk part only - > > which uses mime/multipart reader basically. > Thank you Tamas... I am already

Re: [go-nuts] Re: default --help flag behavior

2017-07-26 Thread Konstantin Khomoutov
On Thu, Jul 20, 2017 at 07:23:23AM +1000, Rob Pike wrote: >>> I realize than running `mybinary --help` returns a nice help message >>> along with a exit status 2. >>> What is the reason it doesn't return 0? [...] >> It's reasonable to consider calling a command with a flag that is not >> defined

Re: [go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Konstantin Khomoutov
On Mon, Jul 24, 2017 at 11:47:44PM -0700, Tamás Gulácsi wrote: > See http://godoc.org/go4.org/syncutil/singleflight for another solution. > If you key by file name/id, and the function compresses when needed > and then returns the (de)compressed file, it'll solve your problem. How is that

Re: [go-nuts] Parsing XML with namespaces in golang

2017-07-25 Thread Konstantin Khomoutov
On Mon, Jul 24, 2017 at 07:44:33PM -0700, emartinez1...@gmail.com wrote: [...] >>> So I'm trying to unmarshal an XML with namespaces in go but i just can't >>> find the right parser to do so. [...] >> type Root struct { >> XMLName struct{} `xml:"urn:MNResultsResults MNResultsResults"`

Re: [go-nuts] [Ann] web2image to take screenshot of web page

2017-07-24 Thread Konstantin Khomoutov
On Sun, Jul 23, 2017 at 04:45:24PM -0700, Tong Sun wrote: > Please take a look at > https://github.com/suntong/*web2image*#-web2image [...] > -d, --headless use chrome-headless docker as client instead of chrome [...] I think it worth mentioning up-front in the README file that this tool

Re: [go-nuts] Parsing XML with namespaces in golang

2017-07-24 Thread Konstantin Khomoutov
On Sun, Jul 23, 2017 at 01:51:41PM -0700, emartinez1...@gmail.com wrote: Hi! > So I'm trying to unmarshal an XML with namespaces in go but i just can't > find the right parser to do so. [...] This (elided for brewity) 8< package main import ( "fmt"

Re: [go-nuts] // go:generate won t work, //go:generate will

2017-04-29 Thread Konstantin Khomoutov
On Sat, 29 Apr 2017 04:33:19 -0700 (PDT) mhhc...@gmail.com wrote: > just a note about the //go:gen comment. > > If there is a space in front of go:gen, it won t work, this, > // go:gen... [...] Let's cite the output of running `go help generate`: | Go generate scans the file for directives,

Re: [go-nuts] Re: [ANN] astilectron - Build cross platform GUI apps with GO and Electron (HTML/JS/CSS)

2017-04-29 Thread Konstantin Khomoutov
On Sat, 29 Apr 2017 01:49:49 -0700 (PDT) Asticode wrote: > - https://github.com/therecipe/qt: like https://github.com/andlabs/ui > it forces you to have a native look [...] It may be just me, but actually a virtue of "having a native look" is one of the best selling points

Re: [go-nuts] Find a string in a file and delete all occurences in the file

2017-04-23 Thread Konstantin Khomoutov
On Sat, 22 Apr 2017 08:08:57 -0700 (PDT) Vikas Kumar wrote: > I am trying to iterate over an array, match the lines in a file and > then delete all occurrences of the lines in the file. > > See this example. > *Array* > var abcd = [5]string{ > "one two", > "three

Re: [go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-19 Thread Konstantin Khomoutov
On Wed, 19 Apr 2017 14:23:09 +0800 hui zhang wrote: > 1) getpath() return a temp string, its c_str() pointer will be > free out of function. So I use malloc I'm not completely sure you're correct. C++ does not implement garbage collection and the object on which you

Re: [go-nuts] what is the best way to to convert c++ std::string to go string in cgo programing?

2017-04-18 Thread Konstantin Khomoutov
On Tue, 18 Apr 2017 02:25:07 -0700 (PDT) hui zhang wrote: > c code > string getstring() {...} > > go > > string gostr = (C.getstring()) Oh, and note that std::string is a fat object. So if getstring() really returns an instance of std::string, and you need to

Re: [go-nuts] Re: memclr optimization and structs

2017-04-15 Thread Konstantin Khomoutov
On Sat, 15 Apr 2017 01:31:27 -0700 (PDT) "'Keith Randall' via golang-nuts" wrote: > > I've been looking into why some of our code wasn't resulting in the > > memclr optimization originally introduced in response to > > https://github.com/golang/go/issues/5373.

Re: [go-nuts] suggestions for the best way to consume Restful services

2017-04-13 Thread Konstantin Khomoutov
On Thu, 13 Apr 2017 05:35:57 -0700 (PDT) Joe Blue wrote: > I have to consume 100's of restful services :) > > So the only way is going to be some sort of parse and codegen > approach. > > Can anyone suggest any libraries or approaches please ? go-swagger may be? It's

Re: [go-nuts] Teaching Elementary/Middle School Kids?

2017-04-11 Thread Konstantin Khomoutov
On Tue, 11 Apr 2017 05:24:46 -0700 (PDT) Bala Natarajan wrote: > I am trying to put together material to teach go to elementary/middle > school kids. Does anyone have public material that I could use as a > guide to prepare this material? Any suggestions on small

Re: [go-nuts] Possible to generate BIOS binaries?

2017-04-10 Thread Konstantin Khomoutov
On Mon, 10 Apr 2017 07:25:55 -0700 (PDT) andrew.penneba...@gmail.com wrote: > Can Go code target BIOS environments, or perhaps Go assembler target > BIOS? Which GOOS, GOARCH settings should be used? Unlikely. IIRC, BIOS code works in the so-called "real" mode of a x86-compatible CPU [1]. That

Re: [go-nuts] what's the max length of an identifier

2017-04-10 Thread Konstantin Khomoutov
On Mon, 10 Apr 2017 09:04:39 -0500 Sam Whited wrote: > On Sun, Apr 9, 2017 at 5:49 PM, Rob Pike wrote: > > To answer your question about creat, ken named it. Why does no one > > ask about aretu? > > I'll bite: what's up with aretu? Jugding from Rob's

Re: [go-nuts] Re: can a program terminate, exit code 2, without an error?

2017-04-07 Thread Konstantin Khomoutov
On Fri, 7 Apr 2017 08:44:26 -0700 (PDT) "'simon place' via golang-nuts" wrote: > using 'kill' to simulate an out-of-memory, i only get the string > 'terminated' and no go-routine dump. I may be wrong but IMO in order to have a goroutine dump you have to kill the

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 14:50:43 +0300 Konstantin Khomoutov <flatw...@users.sourceforge.net> wrote: > > I get string which contains: [...] > What you're dealing with is a typical set of headers of a so-called > "MIME-formatted" e-mail message followed by its body.

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 04:00:20 -0700 (PDT) Ain wrote: > I get string which contains: > > MIME-Version: 1.0 > content-type: text/xml > content-transfer-encoding: base64 > > PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPD94bWwtc3R5bGVzaGVldCB0 > ... > > > ie there are

Re: [go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-06 Thread Konstantin Khomoutov
On Thu, 6 Apr 2017 02:04:29 -0700 (PDT) Kemal Hadimli wrote: > Isn't the select processing order random? IIRC the only guarantee is > "default" case is handled as a low priority. > > So, something like this maybe? > > select { > case errCh <- err: > default: > select { >

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 07:27:17 -0700 Ian Lance Taylor wrote: > >> When you insert a value keyed by S{}, the compiler creates a value > >> of type I which has S as its dynamic type and S{} as its value. > >> > >> The program as speficied panics with > > > > > > Apologies if it

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 02:40:31 -0700 (PDT) Paul Jolly wrote: > *I couldn't find anything previously on the question below, but as > ever would appreciate any pointers to prior questions/issues etc.* > > Consider the following (playground >

Re: [go-nuts] I'm stuck with function onEvict("key", t) used as value

2017-04-03 Thread Konstantin Khomoutov
On Sun, 2 Apr 2017 16:10:57 -0700 (PDT) ono...@gmail.com wrote: > In short, I'm trying to cast type of > function(string, sometype) -> function(interface{}, interface{}) > here is the code: > > https://play.golang.org/p/_ZCT8m_m_0 > > I've tried like 10 possible options, and I believe I just

Re: [go-nuts] Re: Go -> C++ transpiler idea: Miracle child or horrible abomination?

2017-03-25 Thread Konstantin Khomoutov
On Sat, 25 Mar 2017 03:49:55 -0700 (PDT) andrewchambe...@gmail.com wrote: > Its a bad idea for many reasons. > > - The actual implementation is harder than convincing someone to just > use the official Go compiler. > - Some features don't map cleanly to C++ > - C++ programmers won't like it, and

Re: [go-nuts] How to return a Go struct to C

2017-03-21 Thread Konstantin Khomoutov
On Tue, 21 Mar 2017 11:23:39 +0300 Konstantin Khomoutov <flatw...@users.sourceforge.net> wrote: [...] Sorry, a couple of assorted fixes: > A sketch would look something like this: > > /* > typedef MediaHandle uint64_t Should be typedef uint64_t Medi

Re: [go-nuts] How to control the symbol visibility of shared lib built from Go

2017-03-21 Thread Konstantin Khomoutov
On Mon, 20 Mar 2017 23:21:20 -0700 (PDT) Song Liu wrote: > Default symbol could break loading multiple shared lib implemented by > different version of go runtime, if there is one symbol with same > name but with different logic. This actually means they won't be compatible

Re: [go-nuts] How to return a Go struct to C

2017-03-21 Thread Konstantin Khomoutov
On Mon, 20 Mar 2017 06:25:01 -0700 (PDT) Song Liu wrote: [...] > struct Media { > > char*Name; > > char*Path; > > uint64_t Size; > > }; [...] > func GetMediaFromDB(filename *C.char) *C.struct_Media { > > > c_struct_media := _Media{} > > >

Re: [go-nuts] []byte to func

2017-03-21 Thread Konstantin Khomoutov
On Tue, 21 Mar 2017 04:48:50 + Harley Laue wrote: > I have some code that I've sat on for some time: > > type Cell int > type Function func() error > > func cellToFunction(c Cell) *Function { > p := unsafe.Pointer(uintptr(c)) > if p == nil { return nil }

Re: [go-nuts] How to accept any function with one return value as a parameter

2017-03-20 Thread Konstantin Khomoutov
On Sun, 19 Mar 2017 13:51:05 -0700 (PDT) aktungmak wrote: > I am trying to write a function that initializes a generic > collection. For adding new items to the collection, the user > specifies a constructor which takes one argument and returns a > pointer to the struct that

Re: [go-nuts] Re: Go - language of the future!

2017-03-19 Thread Konstantin Khomoutov
On Sat, 18 Mar 2017 05:31:20 -0700 (PDT) mhhc...@gmail.com wrote: [...] > For those which are language designers, comparing the language to > such things > like haskell is made in an attempt to make the best language design > (small ego trip here ?), > not the most practical, effective IRL

Re: [go-nuts] Does it make sense to make expensive syscalls from different goroutines?

2017-03-18 Thread Konstantin Khomoutov
On Sat, 18 Mar 2017 03:50:39 -0700 (PDT) Vitaly Isaev wrote: [...] > Assume that application does some heavy lifting with multiple file > descriptors (e.g., opening - writing data - syncing - closing), what > actually happens to Go runtime? Does it block all the

Re: [go-nuts] uint type safety in go

2017-03-17 Thread Konstantin Khomoutov
On Tue, 14 Mar 2017 07:12:01 -0700 Ian Lance Taylor wrote: > > I was thinking about the type safety of uint in go, and comparing > > it for a similar problem. > > > > If I have this go code: > > > > var x uint > > x-- > > > > The value of x is then the maximal value of uint,

Re: [go-nuts] Re: Is there functionality in golang.org/x/crypto/ssh to close a SSH connection server-side after N number of (password) tries?

2017-03-16 Thread Konstantin Khomoutov
On Thu, 16 Mar 2017 03:07:44 -0700 (PDT) ikkini wrote: > For anyone trying this: If you 'break userAuthLoop, you'll end up > below the label, which equals success. Probably not what you want :/ > instead, I'm now using 'break' and authErr, which gives me the > desired behavior.

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Konstantin Khomoutov
On Mon, 13 Mar 2017 23:22:54 -0700 (PDT) Albert Tedja wrote: > I was using godeps before and now govendor, and never felt 100% happy > with either one. I have some feedback of how I think the package > management tool should work from the developer perspective, and here >

Re: [go-nuts] RSQL, a lighweight clone of Microsoft SQL Server written in Go

2017-03-14 Thread Konstantin Khomoutov
On Mon, 13 Mar 2017 13:13:39 -0700 (PDT) nicolas riesch wrote: > I have developed RSQL, a *lighweight clone of Microsoft SQL Server*, > which runs on Linux and can execute T-SQL scripts. [...] Do I understand correctly that RSQL does not speak (any version of) MS-TDS

Re: [go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-13 Thread Konstantin Khomoutov
On Sun, 12 Mar 2017 17:36:53 -0700 (PDT) st ov wrote: > > > What happens when appending to a slice exceeds the backing > > > capacity? > > > > If the capacity of s is not large enough to fit the additional > > values, append allocates a new, sufficiently large underlying

Re: [go-nuts] thread safety of map when each goroutine access a different key

2017-03-13 Thread Konstantin Khomoutov
On Sun, 12 Mar 2017 23:39:59 -0700 (PDT) Albert Tedja wrote: > I know map itself isn't threadsafe, but I am just wondering how > threadsafe it is if you can be absolutely sure that each goroutine > accesses a different key in the map. > Say, goroutine 1 accesses mymap["1"]

Re: [go-nuts] How to test for unicode property "Variation Selector"

2017-03-10 Thread Konstantin Khomoutov
On Fri, 10 Mar 2017 05:03:25 -0800 (PST) JohnGB wrote: > I have some text that I'm processing which includes emoji. I'm > trying to strip out all the emoji by using checking whether a rune > fulfils unicode.IsSymbol(). This strips out the emoji, but it seems > that some

Re: [go-nuts] Re: gwenn/gosqlite, go1.8, runtime error: cgo argument has Go pointer to Go pointer

2017-03-08 Thread Konstantin Khomoutov
On Wed, 8 Mar 2017 08:17:30 -0800 (PST) Basile Starynkevitch wrote: > > So if you're not really tied to SQLite as such (and picked it > > merely because you're familiar with it or because it's a sane go-to > > choice for single-file structured data persistence solution)

Re: [go-nuts] Re: gwenn/gosqlite, go1.8, runtime error: cgo argument has Go pointer to Go pointer

2017-03-08 Thread Konstantin Khomoutov
On Wed, 8 Mar 2017 07:54:14 -0800 (PST) Basile Starynkevitch wrote: > > It's quite straightforward: gwenn/gosqlite has an error, by passing > > a Go pointer to the C side. This check is in effect since Go1.6. > > > > You should try to refresh your gosqlite library, or

Re: [go-nuts] Cross compiling from Windows to Linux produces non-working go routines

2017-03-08 Thread Konstantin Khomoutov
On Wed, 8 Mar 2017 06:20:25 -0800 (PST) asci...@gmail.com wrote: > I've made this test program > > > package main > > import "fmt" > > func func1() { > fmt.Println("running func1") > for { > > } [...] > func main() { > > go func1() > fmt.Println("run func1") > go

Re: [go-nuts] How to create unique IDs when ranging over data in Golang and use in Javascript

2017-03-07 Thread Konstantin Khomoutov
On Tue, 7 Mar 2017 15:42:11 +0530 Rejoy Nair wrote: > Thanks a lot!. Your answers have been helpful. I was also provided > with a very good solution from another forum that I 'll post that > here for the benefit for anybody who 'd come across this post. You mean

Re: [go-nuts] How to create unique IDs when ranging over data in Golang and use in Javascript

2017-03-06 Thread Konstantin Khomoutov
On Mon, 6 Mar 2017 23:30:20 -0800 (PST) Rejoy wrote: > I am getting data from the server and iterating over it to create a > table and then I am using a form to store an id to local storage > using javascript. Here is code snippet > > > Product ID This loop >

Re: [go-nuts] Re: How can I implement a TCP server using a model which similar to epoll (or kqueue, IOCP) rather than just using goroutine for each client?

2017-03-06 Thread Konstantin Khomoutov
On Mon, 6 Mar 2017 04:31:50 -0800 (PST) Nick Rio wrote: [...] > I really hope they can add that (IO Notify Poll?) into Golang so I > can implement my server in other models instead of > One-Connection-One-Goroutine one. The real problem with I/O notifications -- as you want

Re: [go-nuts] Re: How can I implement a TCP server using a model which similar to epoll (or kqueue, IOCP) rather than just using goroutine for each client?

2017-03-06 Thread Konstantin Khomoutov
On Mon, 6 Mar 2017 12:01:43 +0300 Konstantin Khomoutov <flatw...@users.sourceforge.net> wrote: > > The application is working right now. Current work for me is to > > found a way to reduce it's memory footprint as it will take at > > least 1GB memory to hold only C10K idle

Re: [go-nuts] Re: How can I implement a TCP server using a model which similar to epoll (or kqueue, IOCP) rather than just using goroutine for each client?

2017-03-06 Thread Konstantin Khomoutov
On Mon, 6 Mar 2017 00:26:11 -0800 (PST) Nick Rio wrote: > The application is working right now. Current work for me is to found > a way to reduce it's memory footprint as it will take at least 1GB > memory to hold only C10K idle connections. > > I know it's mainly me

Re: [go-nuts] sqlEZ: the easiest way to use a SQL database

2017-03-05 Thread Konstantin Khomoutov
On Sun, 5 Mar 2017 12:42:24 +0200 Janne Snabb wrote: > > After seeing a need for simplifying SQL databases in Go, I have > > written a new package that makes it very easy to do basic SELECT, > > INSERT, and UPDATE database operations. Essentially you define a > > struct that

Re: [go-nuts] A naive question, why not move the len and cap fields of string and slice types into the underlying types?

2017-03-03 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 23:49:52 -0800 (PST) T L wrote: > After all, the len and cap fields of any value of string and slice > values are immutable. Could you elaborate? Are you suggesting to replace var s []string if len(s) ... if cap(s) ... with if s.len ... if

Re: [go-nuts] decoding various JSON in specific way (according to first JSON name)

2017-03-03 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 12:25:47 -0800 (PST) Basile Starynkevitch wrote: > This question is related to that one > > (which gives more detailed motivation). > > Assume I have some public type > Person

Re: [go-nuts] Re: Can I edit/add struct tag at runtime?

2017-03-02 Thread Konstantin Khomoutov
> > Hi, someone has the solution? > [...] Note that since 1.8 Go ignores tags on type conversions [1] so if you're actually dealing with an "XY problem" [2] -- trying to monkey-patch a struct type's tags at runtime to make it behave differently under different circumstances when (un)marshaling

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 03:35:39 -0800 (PST) Basile Starynkevitch wrote: [...] > > JSON itself doesn't distinguish between integers and floats so it > > could be a bad fit for your use case. [...] > In theory you are right, json.org don't make the difference. In > practice,

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 02:29:22 -0800 (PST) Basile Starynkevitch wrote: > I want to JSON encode a float64 point number always as a JSON float, > so 1.0 should be encoded as 1.0 not as 1 because at decoding time I > want to distinguish them. [...] Use custom type with a

Re: [go-nuts] Regarding os.Stdout

2017-03-01 Thread Konstantin Khomoutov
On Sun, 26 Feb 2017 16:53:48 -0800 (PST) Curtis Paul wrote: > I have the following code. > > How might I parse the os.Stdout data into a map? > > Basically I want to read audio interfaces and put them in some sort > of data structure. Can you elaborate on your approach

Re: [go-nuts] Go Windows vs Linux networking stack differences

2017-02-22 Thread Konstantin Khomoutov
On Wed, 22 Feb 2017 04:43:01 -0800 (PST) Luke Mauldin wrote: > One of the things I love about Go is its ability to write code in one > OS and easily cross-compile and deploy that code to another OS. Can > someone help me understand the differences in Windows vs Linux Go >

Re: [go-nuts] Re: Syscall trouble with parameter handling

2017-02-22 Thread Konstantin Khomoutov
On Tue, 21 Feb 2017 22:55:18 -0800 (PST) snmed wrote: > Has anyone a hint, what i'm doing wrong with the Call arguments? I > think the last parameter is the problematic one, but i can't figure > out how to pass that argument. A couple of ideas: * [1] Features a

Re: [go-nuts] Go UDP performance

2017-02-21 Thread Konstantin Khomoutov
On Mon, 20 Feb 2017 13:02:15 -0800 Tharaneedharan Vilwanathan wrote: > Hi All, > > I am trying to send a lot of UDP packets from Go code but I realized > UDP performance is too low. The max I was able to do is about > 160Mbps. This is in Ubuntu 16.10 on x86_64 (i7-6700HQ). >

Re: [go-nuts] History: Does the _ (Blank identifier) trace its history back to VI's or something earlier?

2017-02-21 Thread Konstantin Khomoutov
On Tue, 21 Feb 2017 01:16:08 -0800 (PST) "'pfitzsimons' via golang-nuts" wrote: > The _ is used as the https://golang.org/ref/spec#Blank_identifier to > ignore right-hand side values in an assignment > (https://golang.org/ref/spec#Assignments) > > In VI(M) _ is

Re: [go-nuts] Re: ActiveState seeking Go community feedback

2017-02-21 Thread Konstantin Khomoutov
On Mon, 20 Feb 2017 12:50:32 -0800 (PST) Kevin Powick wrote: [...] > I'm not really up on Activestate's involvement with Go, but have they > contributed to the development or promotion of Go in any significant > way? I'm not up with their involvement in Go as well, but I

Re: [go-nuts] Go 1.8 released. What's new?

2017-02-20 Thread Konstantin Khomoutov
On Mon, 20 Feb 2017 22:32:06 -0800 (PST) pltvs wrote: > What's new in Go 1.8 We gather what's new in the new releases via the officially published release notes. For Go 1.8 that's [1]. 1. https://golang.org/doc/go1.8 --

Re: [go-nuts] Arguments for writing fast, high-load servers in Go instead of Scala?

2017-02-20 Thread Konstantin Khomoutov
On Fri, 17 Feb 2017 22:55:37 -0800 (PST) Will Faught wrote: > I want to make the case to a software architect where I work that we > should write some fast, high-load servers we need in Go rather than > Scala. What pragmatic arguments should I use? I do not do Scala but

Re: [go-nuts] will GC close unused connection ?

2017-02-16 Thread Konstantin Khomoutov
On Thu, 16 Feb 2017 00:29:04 -0800 (PST) caspia...@gmail.com wrote: > > > Will GC close unused connection ? > > > > No. At least not directly. A finalizer can possibly do that and > > finalizers are possibly invoked by the GC. [...] > Means yes, GC will close unused connection, just indirectly? >

Re: [go-nuts] Re: fmt: Why Golang doesn't have fmt.Printlnf?

2017-02-08 Thread Konstantin Khomoutov
On Wed, 08 Feb 2017 09:52:49 + Justin Israel wrote: > > fmt package have no *lnf method, but in other langs, > > sometimes it implements Printlnf. > > Is there any reason? > > yes, I know but other languages support it as default, isn't it? > *some* languages

Re: [go-nuts] File transfer,but file size is zero

2017-02-07 Thread Konstantin Khomoutov
On Tue, 7 Feb 2017 02:01:51 -0800 (PST) Robert Hsiung wrote: > I tried to upload file via SFTP,but the file size is zero when it > is done.Any suggestions? Thanks so much. [...] > srcFile, err := os.Open("F:/NCA/20161027-1.csv") [...] > dstFile, err :=

Re: [go-nuts] jq (JSON Query) write support?

2017-02-06 Thread Konstantin Khomoutov
On Mon, 6 Feb 2017 02:20:31 -0800 (PST) omarshariffdontlik...@gmail.com wrote: > Just a quick one - anyone know of a JQ package that supports > modifying values that match? I've found several packages that support > reading values but none that support modifying values on match. Quick searching

Re: [go-nuts] Go Fonts: request for feedback

2017-02-04 Thread Konstantin Khomoutov
On Fri, 3 Feb 2017 11:25:20 +1100 Nigel Tao wrote: > Bigelow & Holmes, the designers of the Go Fonts, are preparing an > update to those fonts. [...] > If you have any other bug reports, feature requests, or just like to > comment in general, please reply to the discussion

Re: [go-nuts] Blabk values when trying to pass a slice to a struct field

2017-02-03 Thread Konstantin Khomoutov
On Fri, 3 Feb 2017 17:48:18 +0530 Rejoy Nair wrote: > > > I am trying to pass a slice of data to a struct field . The field > > > has a type of another struct. I get blank values in the output. > > > > > > Here is the code: https://play.golang.org/p/-YZ7UUI--D > > > > > > I 'd

Re: [go-nuts] Blabk values when trying to pass a slice to a struct field

2017-02-03 Thread Konstantin Khomoutov
On Fri, 3 Feb 2017 03:32:00 -0800 (PST) Rejoy wrote: > I am trying to pass a slice of data to a struct field . The field has > a type of another struct. I get blank values in the output. > > Here is the code: https://play.golang.org/p/-YZ7UUI--D > > I 'd like to understand

Re: [go-nuts] Re: I know finalizers are not promised to be called, but is it too not promised?

2017-01-28 Thread Konstantin Khomoutov
On Sat, 28 Jan 2017 07:05:13 -0800 (PST) T L wrote: [...] > My understanding is finalisers are guaranteed to run for some cases, > but not for some other cases, for a long running program. > If any cases are not guaranteed to run, then SetFinalizer would be > totally

Re: [go-nuts] GolangRT Docs?

2017-01-27 Thread Konstantin Khomoutov
On Thu, 26 Jan 2017 19:57:22 -0800 (PST) T L wrote: > > It depends. A call to new can (and will, often) give you a pointer > > to a stack allocated object. If you pass that pointer to something > > like fmt.Println() you'll see the object escape to the heap, get > > flagged

Re: [go-nuts] Re: Tracking down logic lock

2017-01-26 Thread Konstantin Khomoutov
On Thu, 26 Jan 2017 07:51:11 + Lee Armstrong wrote: > > Send HUP (kill -HUP pid or pressing Ctrl+\ on the terminal), when > > the program is locked up, save the resulting stack trace, and > > inspect. It'll list all running/blocked goroutines, and the point > > of the

Re: [go-nuts] How to use []interface{} in generic programing

2017-01-24 Thread Konstantin Khomoutov
On Mon, 23 Jan 2017 17:47:48 -0800 (PST) hui zhang wrote: > type IReset interface { >Reset() > } > type Fight struct { >hp,mp int > } [...] > func reset1(x IReset){ >x.Reset() > } > func reset(x []IReset) { >for i := range x { > x[i].Reset() >} > }

Re: [go-nuts] Re: How to generate generic code with generate?

2017-01-23 Thread Konstantin Khomoutov
On Mon, 23 Jan 2017 21:39:39 -0800 (PST) hui zhang wrote: > > With github.com/badgerodon/goreify you can do this: > As this github auther says: > I found gengen after implementing > most of this functionality. It follows a similar

Re: [go-nuts] How to seek in file use bufio.Reader?

2017-01-19 Thread Konstantin Khomoutov
On Wed, 18 Jan 2017 23:35:30 -0800 (PST) hui zhang wrote: > I am using bufio.Reader and binary.Read > to read binary from file, I want to seek in the file or bufio.Reader > Below code does not work > > fi.Seek(0, os.SEEK_SET) Does not work for bufio.Reader > > >

Re: [go-nuts] why there are so many ways to read file

2017-01-19 Thread Konstantin Khomoutov
On Thu, 19 Jan 2017 00:05:46 -0800 (PST) hui zhang wrote: > check below link > > http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file-using-golang > > It offer 3 ways. > os > *bufio* > *ioutil* There's just a single way to read a file -- using the

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread Konstantin Khomoutov
On Wed, 18 Jan 2017 23:00:33 -0800 (PST) hui zhang wrote: > so the file seek does not work in bufio.Read ? You might need to use the Reset() method of your bufio.Reader value before you reposition the pointer in the underlying opened file. Please see `go doc

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread Konstantin Khomoutov
On Wed, 18 Jan 2017 22:54:31 -0800 (PST) hui zhang wrote: [...] > > 2. So we now read the docs on os.File: > > > > $ go doc os.File > > > >...and see all of its methods there, inclusing Seek(). > > > > 3. So we read the docs on it: > > > > $ go doc

Re: [go-nuts] how to seek in file using go

2017-01-18 Thread Konstantin Khomoutov
On Wed, 18 Jan 2017 22:22:48 -0800 (PST) hui zhang wrote: [...] >fi, err := os.Open("./output.bin") [...] >fi.seek()? The usual drill is: 1. Get the documentation on os.Open(): $ go doc os.Open Notice what it returns in its 1st return value has

Re: [go-nuts] Reading an .ini file

2017-01-17 Thread Konstantin Khomoutov
On Sat, 14 Jan 2017 08:03:45 -0800 (PST) buc...@gmail.com wrote: > Rankest beginner here. Trying to learn Go by converting an old > Visual Basic application to Go (yeah, right) on Windows 10 (got all > the database stuff working with both postgre and sqlite!) The > application needs to read an

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Konstantin Khomoutov
On Mon, 16 Jan 2017 13:35:07 -0800 (PST) Deepak Jain wrote: > util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json", > artifact. dir)) > > func ExecuteCommandWithOuput(cmd *exec.Cmd) { > output, err := cmd.Output() > if err != nil { > log.Print("Error executing

[go-nuts] Is this a compiler bug?

2017-01-06 Thread Konstantin Khomoutov
Isn't it that bit from [1] which deals with the arrays and structures of size 0? I mean that part which says distinct values of such types might have the same address in memory. 1. https://golang.org/ref/spec#Size_and_alignment_guarantees -- You received this message because you are

Re: [go-nuts] Re: How to use ~/ in terminal with go program?

2017-01-04 Thread Konstantin Khomoutov
On Tue, 3 Jan 2017 00:00:27 -0800 (PST) Caleb Doxsey wrote: > What's wrong with a library? > > This particular library is used by vagrant and dozens of other > software projects, it's cross platform and handles all the edge cases. > > Never relying on 3rd party libraries is a

Re: [go-nuts] How to create a function to Return Map value type: New Year's Eve assignment

2016-12-31 Thread Konstantin Khomoutov
On Sat, 31 Dec 2016 05:31:30 -0800 (PST) mrchong...@gmail.com wrote: > I am spending my New Year's eve watching Thai TV and coding. > > below is the function I created to return a map. My function returns > nil. When "crossposting" [2], please always mention alternative venues you've used to

Re: [go-nuts] when you want to template a struct with private fields....

2016-12-31 Thread Konstantin Khomoutov
On Sat, 31 Dec 2016 07:45:27 -0800 (PST) Joseph Lorenzini wrote: > So I know why this can't work. :) My question is the following: if > you have a type that you want to be private (e.g struct), how would > you template that data? Use a different data structure? Use >

Re: [go-nuts] Re: Why there is no container/set

2016-12-31 Thread Konstantin Khomoutov
On Fri, 30 Dec 2016 11:26:16 -0800 (PST) buchanae.o...@gmail.com wrote: > On Saturday, December 3, 2011 at 1:32:02 AM UTC-8, James Chow wrote: > > > > I used "set" in java and c++, why there is no such container in > > golang pkg-tree? > > > Back to the original question, container/set seems like

Re: [go-nuts] Re: How to use ~/ in terminal with go program?

2016-12-30 Thread Konstantin Khomoutov
On Fri, 30 Dec 2016 06:12:46 + Aurélien DESBRIÈRES wrote: > > > The original code is https://play.golang.org/p/CTbhTC50eE > > > It is write to works as: > > > > > > go run gocat.go > > > > > > Here is how it works at this time. > > > > > > $ go run gocat.go > >

Re: [go-nuts] custom json unmarshaling between object or arrays

2016-12-28 Thread Konstantin Khomoutov
On Wed, 28 Dec 2016 21:55:33 -0800 (PST) Sathish VJ wrote: > I'm trying to do custom json unmarshaling when there could be an > error. > > In case there is an error, it will have json like: { "error": "err > msg"} Else, it could be anything. > > If it is another json

Re: [go-nuts] How to use ~/ in terminal with go program?

2016-12-28 Thread Konstantin Khomoutov
On Wed, 28 Dec 2016 10:25:54 -0300 Aldrin Leal wrote: > > As explain ~/ in golang > > , I am trying to > > request the user to cat a file with a gocat program. > > > > The point is that if the user tell to the terminal the full

Re: [go-nuts] Modern Garbage Collection Article

2016-12-19 Thread Konstantin Khomoutov
On Mon, 19 Dec 2016 20:56:39 -0800 (PST) Tyler Compton wrote: > https://medium.com/@octskyward/modern-garbage-collection-911ef4f8bd8e#.c48w4ifa7 > > Thoughts? How accurate is this article? If it is, why, historically, > is the work being done on the GC so concentrated on

Re: [go-nuts] are functions garbage collected?

2016-12-19 Thread Konstantin Khomoutov
On Mon, 19 Dec 2016 03:52:40 -0800 (PST) "Jason E. Aten" wrote: > In the context of having a REPL for Go (and the new plugin support!) > where we would generate functions at runtime, I'm curious if the > garbage collector could be made to scan (perhaps on cue) some >

Re: [go-nuts] package containing standard CA roots?

2016-12-18 Thread Konstantin Khomoutov
On Sat, 17 Dec 2016 10:41:33 -0800 (PST) Rick wrote: > Alpine is a lightweight option with official Docker images. You can > install the CERTS using the Alpine package manager: > > # apk --no-cache add ca-certificates && update-ca-certificates All-in-all,

<    1   2   3   >