Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Dan Kortschak
exec.Command does not invoke a shell, the `>' you use in bash is a shell function (https://www.gnu.org/software/bash/manual/bash.html#Redi rections). Note that the example for CombinedOutput invokes "sh" as the command with "-c", "ls... (https://golang.org/pkg/os/exec/#example_Cmd_

[go-nuts] Re: Simple exec.Command() program

2017-11-12 Thread Nilsocket
package main import ( "os" "os/exec" ) func main() { cmd := exec.Command("ls") null, _ := os.Open(os.DevNull) defer null.Close() cmd.Stdout = null cmd.Run() } What you were trying to do is, redirecting output of ls to /dev/null. `ls` is the name of the command. `>`

[go-nuts] Bulky (Payload) Structs in API

2017-11-12 Thread dc0d
It is a Go best practice to "accept interfaces, return concrete types". Which helps greatly in implementing different architectures/designs (like Clean Architecture or the like). There are times that a package is used which returns fat structs (as the concrete type) - mostly POGO. Problem:

[go-nuts] How to convert from []byte to []uint32?

2017-11-12 Thread Christian LeMoussel
I have a data stream of bytes and I'd like to get array of int32 (from four bytes). func convertCharToInt32(buffer string) []uint32 { const SIZEOF_INT32 = 4 var hh = make([]byte, 2) var cbuffer = make([]byte, len(buffer)/2) var hbuffer = make([]uint32, len(cbuffer)/SIZEOF_INT32)

Re: [go-nuts] Re: network programming about go

2017-11-12 Thread 2891132love
I know your meaning.But I still can't get the result I want. this is the server program: package main import ( "fmt" "net" "os" "strings" ) func main() { listener, err := net.Listen("tcp", "0.0.0.0:400") checkError(err) for i := 0; i < 10; i++ { conn, err := listener.Accept() if err != nil {

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread andrey mirtchovski
">" is a special character interpreted by your shell. On Sun, Nov 12, 2017 at 8:35 PM, wrote: > package main > > import( > "fmt" > "os/exec" > ) > > func main () > cmd := exec.Command("ls", ">", "/dev/null") > output, err := cmd.CombinedOutput() > if err != nil { >

[go-nuts] Re: Bulky (Payload) Structs in API

2017-11-12 Thread Egon
One possibility is copy-paste the structure and convert at call boundaries. https://play.golang.org/p/5LFw6U3yi6 But, can you show a real-world example to ground the conversation? + Egon On Monday, 13 November 2017 08:48:18 UTC+2, dc0d wrote: > > It is a Go best practice to "accept interfaces,

[go-nuts] Simple exec.Command() program

2017-11-12 Thread bucarr
package main import( "fmt" "os/exec" ) func main () cmd := exec.Command("ls", ">", "/dev/null") output, err := cmd.CombinedOutput() if err != nil { fmt.Println(fmt.Sprint(err) + ": " + string(output)) } When I run this go program I get: exit status: 1: ls: >:No such file or directory /dev/null

[go-nuts] Re: Bulky (Payload) Structs in API

2017-11-12 Thread dc0d
BTW another approach that I've tried is to use Type Aliases. A third package created and type aliases (with the same names) defined for those POGO payloads. Then type aliases (and interfaces) from this third package can be used in upper/other packages. But I've not used it heavily because I

Re: [go-nuts] Re: OpenCL or CUDA bindings

2017-11-12 Thread Ron Evans
Hello, all I've been working on some similar problems calling Windows APIs from Go. This looks promising, in order to use .lib files from within MinGW: https://stackoverflow.com/questions/11793370/how-can-i-convert-a-vsts-lib-to-a-mingw-a Anyone tried this? On Sunday, November 12, 2017 at

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Caleb Spare
ls is a bash builtin. You can probably invoke the ls command with /bin/ls. But also, passing ">" as an argument to exec.Command doesn't do what you want. > is a redirection for a shell and exec.Command is not a shell. I'm not sure what you're trying to accomplish, but here are two things you

[go-nuts] Re: Bulky (Payload) Structs in API

2017-11-12 Thread dc0d
Thanks! That's what I do, though not happy with it. I had to write some helper apps and scripts (I'm not fluent in playing with Go ast yet). An example would be the API to Telegram Bot (package ). Requests and responses from the API are

[go-nuts] Re: Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Petar Maymounkov
And thanks! On Sunday, November 12, 2017 at 11:40:51 AM UTC-5, Petar Maymounkov wrote: > > Inline: > > On Saturday, November 11, 2017 at 2:52:30 PM UTC-5, Dave Cheney wrote: >> >> Hi, >> >> Thanks for following up here. >> >> >> >> On Sunday, 12 November 2017 03:35:27 UTC+11, Petar Maymounkov

Re: [go-nuts] Re: How can I convert an byte array into int array?

2017-11-12 Thread Christian LeMoussel
byte array come from GPU card. Why this question? Garanti sans virus. www.avast.com

[go-nuts] Re: Zip file created by archive/zip can't be opened on Windows machine

2017-11-12 Thread Klaus Post
Hi! Windows cannot extract password protected ZIP files without third party software. Sorry, but it a beef you need to take with Microsoft. ref:

Re: [go-nuts] Re: How can I convert an byte array into int array?

2017-11-12 Thread Jan Mercl
On Sun, Nov 12, 2017 at 2:41 PM Christian LeMoussel wrote: > byte array come from GPU card. > Why this question? See https://commandcenter.blogspot.de/2012/04/byte-order-fallacy.html -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Efficient to copy Hash?

2017-11-12 Thread roger peppe
On 12 November 2017 at 00:49, wrote: > Go 1.10 adds MarshalBinary and UnmarshalBinary to each of the hash.Hash > implementations. You can use those to effectively copy the hash structure. Wow, that's interesting (and potentially very useful)! Is there anything in the

Re: [go-nuts] Golang capacity

2017-11-12 Thread Bakul Shah
On Sun, 12 Nov 2017 15:45:40 + Jesper Louis Andersen wrote: > > To elaborate on Jan's point: > > If you extended capacity every time you called append, then you will have > to reallocate and copy data quite a lot. So a clever system pushes a little > bit

[go-nuts] Re: Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Petar Maymounkov
Inline: On Saturday, November 11, 2017 at 2:52:30 PM UTC-5, Dave Cheney wrote: > > Hi, > > Thanks for following up here. > > > > On Sunday, 12 November 2017 03:35:27 UTC+11, Petar Maymounkov wrote: >> >> Consider a chain of functions that call each other: >> >> >> func f1(x X) { ... f2(y) ... }

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Bakul Shah
On Nov 11, 2017, at 5:33 AM, Petar Maymounkov wrote: > > Generally, such a chain of statically-typed invocations will fall within the > domain of the SSA optimizer and will be rewritten (theoretically) optimally. > > > > The issue arises when the invocation chain is

[go-nuts] Re: How can I convert an byte array into int array?

2017-11-12 Thread Christian LeMoussel
I find this solution : const SIZEOF_INT32 = 4 var cbuffer = make([]byte, 28) var hbuffer = make([]uint32, len(cbuffer)/SIZEOF_INT32) for i := range hbuffer { hbuffer[i] = uint32(binary.LittleEndian.Uint32(cbuffer[i*SIZEOF_INT32 : (i+1)*SIZEOF_INT32])) } By default,

[go-nuts] How can I convert an byte array into int array?

2017-11-12 Thread Christian LeMoussel
I have []byte, How can I convert this to []int? var cbuffer = make([]byte, 28) var hbuffer = [8]int{0, 0, 0, 0, 0, 0, 0} -- 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

[go-nuts] ACCU 2018 Call for Session Proposals

2017-11-12 Thread Russel Winder
Last five days to submit proposals for #ACCUConf 2018. Goto https://cfp.conference.accu.org. Gen Ashley, Hadi Hariri, Seb Rose, and Lisa Lippincott will be the keynote speakers. -- Russel. == Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road

[go-nuts] Re: How can I convert an byte array into int array?

2017-11-12 Thread Christian LeMoussel
To detect byte order for golang, I find this package* GoEndian * -- 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

Re: [go-nuts] Golang capacity

2017-11-12 Thread Jan Mercl
On Sun, Nov 12, 2017 at 12:00 PM wrote: > The question is capacity. > Why not : 0,1,2,3,4,5 as length ? Because O(n) is better than O(n^2). -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: network programming about go

2017-11-12 Thread 2891132love
So how to modify my program correctly??I try to add read in different place but it still can't get the result I want. 在 2017年11月12日星期日 UTC+8上午5:05:49,Justin Israel写道: > > > > On Sun, Nov 12, 2017, 10:03 AM Justin Israel > wrote: > >> >> >> On Sat, Nov 11, 2017, 9:55 PM

Re: [go-nuts] Re: How can I convert an byte array into int array?

2017-11-12 Thread Jan Mercl
On Sun, Nov 12, 2017 at 11:48 AM Christian LeMoussel wrote: > To detect byte order for golang, I find this package GoEndian Where does the byte array come from? Depending on that information you may find you don't need to know the byte

Re: [go-nuts] How can I convert an byte array into int array?

2017-11-12 Thread Jan Mercl
On Sun, Nov 12, 2017 at 10:37 AM Christian LeMoussel wrote: > I have []byte, How can I convert this to []int? What encoding is used for those integers? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] Golang capacity

2017-11-12 Thread Lucio
One could lie about it, I suppose, but then you'd need to have an additional (hidden) value and that certainly does not seem worth it. Lucio. On Sunday, 12 November 2017 13:39:59 UTC+2, Jan Mercl wrote: > > On Sun, Nov 12, 2017 at 12:00 PM wrote: > > > The question is

Re: [go-nuts] Golang capacity

2017-11-12 Thread Jesper Louis Andersen
To elaborate on Jan's point: If you extended capacity every time you called append, then you will have to reallocate and copy data quite a lot. So a clever system pushes a little bit more capacity in at the end to avoid such copies whenever an append happens. It is a trade-off between space usage

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Jesper Louis Andersen
In addition to tail-call optimization, you also need a "contification" pass, which removes intermediate functions in the SSA basic blocks where possible. The observation is that if a function always returns to the same point, then it can be turned into a continuation, which is exactly what an SSA

Re: [go-nuts] Golang capacity

2017-11-12 Thread Jesper Louis Andersen
I haven't tried it out, but I think it will work because each new slot is hit twice: it is filled with data, and it is copied away again. So when you expand from n to 2*n, you may be able to arrange that you have exactly n credits in the bank which can be used to pay for the copy. This might

Re: [go-nuts] Golang capacity

2017-11-12 Thread Bakul Shah
On Sun, 12 Nov 2017 17:41:18 + Jesper Louis Andersen wrote: > > I haven't tried it out, but I think it will work because each new slot is > hit twice: it is filled with data, and it is copied away again. So when you > expand from n to 2*n, you may be able to

Re: [go-nuts] Efficient to copy Hash?

2017-11-12 Thread andrey mirtchovski
> Is there anything in the Go docs that indicates that? https://tip.golang.org/pkg/hash/#Hash (from https://go-review.googlesource.com/c/go/+/66710) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Re: network programming about go

2017-11-12 Thread Justin Israel
On Sun, Nov 12, 2017, 10:11 PM <2891132l...@gmail.com> wrote: > So how to modify my program correctly??I try to add read in different > place but it still can't get the result I want. > Make sure your server is doing: read, write, read, write And your client is doing: write, read, write, read

Re: [go-nuts] Efficient to copy Hash?

2017-11-12 Thread roger peppe
Ah, thanks, I missed that. I think the individual packages should mention it too. I just created https://go-review.googlesource.com/c/go/+/77251 to address that. On 12 November 2017 at 18:17, andrey mirtchovski wrote: >> Is there anything in the Go docs that indicates

[go-nuts] Re: Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Dave Cheney
In the gc compiler inlining occurs early on in the parse and import phase, it’s is independent of the ssa passes later. Gccgo may handle this differently. Can the gc compiler handle 10 functions in a package. I’m going to go with yes, but you’ll probably need an enormous amount of memory. The

[go-nuts] Garbage collection and multi-purpose pointers

2017-11-12 Thread gituliar
Hi guys, Go gurus, please, help me with the following problem. I want to build a simple calculator for algebraic expression, aka computer algebra system. In this calculator every object has a `type Ex uintptr` (expression). An optimization I want to introduce is that atomic objects, like

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Petar Maymounkov
Yep, eventually it will come down to experiments. Or I might end up implementing an optimizer before the Go compiler. Thanks! On Sun, Nov 12, 2017 at 4:01 PM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > On Sun, Nov 12, 2017 at 9:15 PM Petar Maymounkov

Re: [go-nuts] Re: OpenCL or CUDA bindings

2017-11-12 Thread heavymetalcookies
I've been having trouble with bindings because I use windows with go and go compiler uses mingw. This means that even on windows, I need the ".a" files rather than the ".lib" files for the linker. The problem is, the cuda-toolkit for windows does NOT give you the .a files. The solution: Use the

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Petar Maymounkov
On Sunday, November 12, 2017 at 12:13:11 PM UTC-5, Bakul Shah wrote: > > On Nov 11, 2017, at 5:33 AM, Petar Maymounkov > wrote: > > > > Generally, such a chain of statically-typed invocations will fall within > the domain of the SSA optimizer and will be rewritten

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Petar Maymounkov
On Sunday, November 12, 2017 at 12:33:11 PM UTC-5, Jesper Louis Andersen wrote: > > In addition to tail-call optimization, you also need a "contification" > pass, which removes intermediate functions in the SSA basic blocks where > possible. The observation is that if a function always

Re: [go-nuts] Garbage collection and multi-purpose pointers

2017-11-12 Thread Jakob Borg
As you guessed, you can’t do this. You’re not allowed to store a pointer as uintptr for any time span longer than a single expression, essentially. Instead, have a real pointer (or interface) field that is nil when not used. //jb On 12 Nov 2017, at 16:49,

Re: [go-nuts] Can/should the SSA optimizer cross package boundaries?

2017-11-12 Thread Jesper Louis Andersen
On Sun, Nov 12, 2017 at 9:15 PM Petar Maymounkov wrote: > This is an interesting suggestion. But it makes me wonder how this > compares against generating directly a bag of LLVM statically-typed > functions > and trying the intelligence of the LLVM SSA optimizer. Do you know if

[go-nuts] what's new with Go in the past year?

2017-11-12 Thread JM
Unfortunately, I have been out of Go land for about a year and want to get back into it. What has added/changed over the past year? Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] Golang capacity

2017-11-12 Thread roger peppe
That's really interesting. I'd always assumed (without really thinking more deeply about it) that amortised appending to a slice was O(n*log(n)). Here's an empirical demonstration, FWIW: https://play.golang.org/p/iLGiyexo1A On 12 November 2017 at 17:56, Bakul Shah wrote: >

[go-nuts] A task runner / simpler Make alternative written in Go

2017-11-12 Thread Andrey Nering
https://github.com/go-task/task I created this in the start of the year because Make is a mess on Windows and I dislike how complicated/obscure is the syntax. It started as a very simple way of running a bunch commands, but then came the feature requests and contributions and it become a

[go-nuts] Why doesn't sync.Cond embed sync.Locker?

2017-11-12 Thread T L
. -- 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, visit https://groups.google.com/d/optout.

Re: [go-nuts] what's new with Go in the past year?

2017-11-12 Thread Michael Jones
In the rear view mirror: https://golang.org/doc/go1.8 https://golang.org/doc/go1.9 through the windscreen: go 1.10 approaching rapifdly On Sun, Nov 12, 2017 at 2:40 PM, JM wrote: > Unfortunately, I have been out of Go land for about a year and want to get > back into it.