Re: [go-nuts] About runtime.globrunqput/globrunqputhead

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 7:54 PM, Lin Hao  wrote:
>
> I mean, sched.midle is a single linked list, but its mode of operation is
> different from sched.runqhead/runqtail, why? (or, Why they used different
> structure?)

The midle list is a list of M's that aren't doing anything.  It
doesn't matter which of them we use when we need one.  They weren't
doing anything anyhow.  So we just add M's on the front of the list
and remove them from the front of the list.

The runqhead/runqtail list is a list of G's that are waiting to run.
The G's on the list have work to do.  If we added G's on the front and
removed them from the front, then the one at the end would not run for
a very long time.  So for runqhead/runqtail we add them at the end and
remove them from the front.  That way every G on the list gets a fair
chance to run.

Ian

-- 
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] About runtime.globrunqput/globrunqputhead

2016-08-31 Thread Lin Hao
Sorry, I haven't expressed clearly. I didn't suggest anything, just
wondering, so I want to ask about it.

I mean, sched.midle is a single linked list, but its mode of operation is
different from sched.runqhead/runqtail, why? (or, Why they used different
structure?)

-- 
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] Re: Who wants to use Go to process your camera's raw files?

2016-08-31 Thread Jonathan Pittman
Does the license need to be the same as the standard Go License if it
starts in another repo and then moves over?

On Wed, Aug 31, 2016 at 8:19 PM, Nigel Tao  wrote:

> On Mon, Aug 29, 2016 at 12:27 PM, Jonathan Pittman
>  wrote:
> > To everyone, I really want to see this live in the golang.org/x/image
> repo.
> > Do we need to create a formal proposal for it to live there?  Should we
> do
> > the initial development in another repo and then move it to the x/image
> repo
> > later?
>
> I'm open to this eventually living under golang.org/x/image/..., but I
> think you'll move faster if you start the initial development in a
> separate repo.
>

-- 
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.


[go-nuts] Go 1.7 vs Go 1.5 performance

2016-08-31 Thread lennykneller
Unfortunately, I don't have Go 1.6 numbers.
I benchmarked my parallel 2-d convex hull program in Go 1.5 and Go 1.7 on 
Windows 64-bit platform. The code uses big rational numbers (math/big.Rat) 
which puts pressure on the GC. I observed noticeable reduction in run 
times: 1-core version of the Go 1.7 code took between 76%-86% wall time of 
the Go 1.5 code. The numbers are even better running on 4 cores: the Go 1.7 
code took between 71%-79% wall time of the Go 1.5 code.

You can see the code and benchmark timings at 
https://github.com/reconditematter/pch2

Well done, the Go Team!

-Lenny-


-- 
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.


[go-nuts] Re: Unable to Get SID in golang

2016-08-31 Thread brainman
On Thursday, 1 September 2016 00:10:39 UTC+10, kumargv wrote:
> I am getting SID of my system using WMI
> 
> >wmic useraccount where name='vijay' get sid
> SID
> S-1-5-21-742204146-2006990925-2362806598-1001
> 
> But still i am not able to get sid structure .

golang.org/x/sys/windows.SID is defined as

type SID struct{}

If you want to convert SID into string, you can do this 
https://play.golang.org/p/vWqQZuQCZC

Alex

-- 
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] unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Dan Kortschak
On Wed, 2016-08-31 at 17:37 -0700, Ian Lance Taylor wrote:
> Set GOARCH in the environment to amd64, not x86_64.  Or don't bother
> to set it at all.
> 
Thanks Ian. Just went through and clean out many GO* vars from
his .profile.

-- 
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] unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 5:19 PM, Dan Kortschak
 wrote:
> One of my users has struck a problem with an install of go1.7 from the
> packages at [1] that has me baffled. I don't use a mac, so I've depleted
> my knowledge of what might be going on here. Can anyone help?

> $ go run hello.go
> cmd/go: unsupported GOOS/GOARCH pair darwin/x86_64

> GOARCH="x86_64"

Set GOARCH in the environment to amd64, not x86_64.  Or don't bother
to set it at all.

Ian

-- 
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.


[go-nuts] Re: unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Dave Cheney
It looks like they've exported GOARCH=x86_64 which is the linux preferred 
word for amd64. They should either remove the GOARCH setting or set it to 
GOARCH=amd64

On Thursday, 1 September 2016 10:19:35 UTC+10, kortschak wrote:
>
> One of my users has struck a problem with an install of go1.7 from the 
> packages at [1] that has me baffled. I don't use a mac, so I've depleted 
> my knowledge of what might be going on here. Can anyone help? 
>
> thanks 
> Dan 
>
> The OS is 10.11.6 on a macbook. 
>
> $ go run hello.go 
> cmd/go: unsupported GOOS/GOARCH pair darwin/x86_64 
> $ go version 
> go version go1.7 darwin/amd64 
> $ which go 
> /usr/local/go/bin/go 
> $ go env 
> GOARCH="x86_64" 
> GOBIN="" 
> GOEXE="" 
> GOHOSTARCH="amd64" 
> GOHOSTOS="darwin" 
> GOOS="darwin" 
> GOPATH="" 
> GORACE="" 
> GOROOT="/usr/local/go" 
> GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" 
> CC="clang" 
> GOGCCFLAGS="-fPIC -fno-caret-diagnostics -Qunused-arguments 
> -fmessage-length=0 
> -fdebug-prefix-map=/var/folders/hp/y4ntgxvx1r58r_0730q_c9bmgp/T/go-build799346258=/tmp/go-build
>  
> -gno-record-gcc-switches -fno-common" 
> CXX="clang++" 
> CGO_ENABLED="0" 
>
>
> [1]https://storage.googleapis.com/golang/go1.7.darwin-amd64.pkg 
>
>

-- 
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] Re: Who wants to use Go to process your camera's raw files?

2016-08-31 Thread Nigel Tao
On Mon, Aug 29, 2016 at 12:27 PM, Jonathan Pittman
 wrote:
> To everyone, I really want to see this live in the golang.org/x/image repo.
> Do we need to create a formal proposal for it to live there?  Should we do
> the initial development in another repo and then move it to the x/image repo
> later?

I'm open to this eventually living under golang.org/x/image/..., but I
think you'll move faster if you start the initial development in a
separate repo.

-- 
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.


[go-nuts] unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Dan Kortschak
One of my users has struck a problem with an install of go1.7 from the
packages at [1] that has me baffled. I don't use a mac, so I've depleted
my knowledge of what might be going on here. Can anyone help?

thanks
Dan

The OS is 10.11.6 on a macbook.

$ go run hello.go 
cmd/go: unsupported GOOS/GOARCH pair darwin/x86_64
$ go version
go version go1.7 darwin/amd64
$ which go
/usr/local/go/bin/go
$ go env
GOARCH="x86_64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -fno-caret-diagnostics -Qunused-arguments
-fmessage-length=0
-fdebug-prefix-map=/var/folders/hp/y4ntgxvx1r58r_0730q_c9bmgp/T/go-build799346258=/tmp/go-build
 -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="0"


[1]https://storage.googleapis.com/golang/go1.7.darwin-amd64.pkg

-- 
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] gomobile init should have a flag if we want only IOS or Android

2016-08-31 Thread Hyang-Ah Hana Kim
What do you think if the error message is modified to clearly include the
instruction for xcode installation?

On Mon, Aug 29, 2016 at 6:03 AM, Abhishek Sinha  wrote:

> While doing gomobile init on OSX, I get the following error
> gomobile: xcrun --show-sdk-path: exit status 1
> xcrun: error: SDK "iphoneos" cannot be located
> xcrun: error: SDK "iphoneos" cannot be located
> xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
>
> Seems like xcode needs to be installed. Shouldn't there be a flag to
> override this as one may exclusively want to use his device for android
> development
>
> --
> 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.
>



-- 
__

-- 
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] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-31 Thread Tim Hawkins
I would have expected that aside from informing about general performance,
one of the purposes for benchmarks would have been to create pressure for
improvement of key features of the laguage, this seems to circumvent this,
im not dure what they are trying to achive. Perhaps restrictions on only
using the language as distributed and its standard lib would be a healthy
constraint to evangelise for.

On 1 Sep 2016 06:53, "Harald Weidner"  wrote:

> Hello,
>
> On Wed, Aug 31, 2016 at 08:44:41AM -0700, 'Eric Johnson' via golang-nuts
> wrote:
>
> > >The Java counterpart of this benchmark does not use the Java build-in
> > >maps, but imports a map implementation for fixed data types from the
> > >fastutil project.
>
> > I hadn't noticed that. That would seem to violate the spirit of the test:
>
> The regex-dna benchmark is even more strange. Neither the measured Go nor
> the
> Java implementation use the standard regexp libs. The Go program imports
> bindings to PCRE, the Java program uses TclRE.
>
> Harald
>
> --
> 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.
>

-- 
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] Cgo Pointer Arithmetic

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 2:06 PM, Luke Mauldin  wrote:
> I modified my example based on the code example you gave at the bottom for
> the pointer arithmetic and that compiled without any go vet errors.  I
> attempted to use the slice whose backing array is the C array
> https://play.golang.org/p/rJoDMu5YAQ but I get a compile error:
> main.go:14: cannot convert cArr (type *Tag) to type *[1048576]Tag

Oh, sorry, you need to drop in another conversion to unsafe.Pointer.

> Another question, if I update my code to use the slice whose backing array
> is the C array, I see the slice type supports 1048576 entries. If I only
> need at most 100 entries, is there a memory penalty imposed by declaring the
> type to support 1048576 entries?  If so, how great is that penalty?

There is no penalty.  It's just a pointer type conversion.  Though if
you are seeing that many entries, then I suspect that you left out the
operation that slices the pointer back down to arrLength (the
[:arrLength:arrLength] at the end of line in the code I sent).

Ian

-- 
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.


[go-nuts] Re: Close a reader to quit a loop without closing its source

2016-08-31 Thread adonovan via golang-nuts
On Wednesday, 31 August 2016 07:48:12 UTC-4, Dave Cheney wrote:
>
> Unfortunately POSIX does not guarantee that close from one thread will 
> unblock another.


To read from a file without waiting longer than a specified time, you need 
to use the POSIX 'select' system call, which you can find at 
syscall.Select.  (It was the inspiration for the Go select statement, but 
whereas Go's select multiplexes channels, POSIX's select multiplexes 
files.)  The select system call is quite a pain to use in Go; you might 
want to take a look at https://github.com/creack/goselect.

-- 
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.


[go-nuts] Using go mobile with Cordova

2016-08-31 Thread Joe Blue
Building html5 Cordova apps is pretty easy.

But I want to put a golang web server being it that is exposing a restful json 
API.
The HTML5 GUI can then call it.
I am using the recent json patch functionality to allow the GUI layer to 
constantly update the db ( boltdb) with changes.

What are my options ?

I am pretty sure that the only way is to use a Cordova plugin that calls over 
http to the local golang server.

But I am stuck with how to do that middle bit.

-- 
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] Cgo Pointer Arithmetic

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 12:47 PM, Luke Mauldin  wrote:
>
> I have questions about pointer arithmetic illustrated by this Play example:
> https://play.golang.org/p/-cZteTY_M2
>
> Questions:
> 1) Is this the best way to do pointer arithmetic in Go to process a C array
> and convert it to a Go slice?
> 2) Go vet gives an error on line 18 but doesn't give much information on how
> to fix the usage of unsafe.Pointer.  Any recommendations?

It's usually simplest to write an expression like
s := (*[1 << 20]Tag)(Carr)[:arrLength:arrLength]
That will give you a slice whose backing array is the C array, without
requiring any copying.  Of course you then have to make sure that C
array lives on the heap as least as long as the slice does.  If that
is an issue, then write
s2 := make([]Tag, arrLength)
copy(s2, s)
To be clear, this assume there are fewer than 1 << 20 entries in the
array, so adjust as needed.


The vet errors for your code are false positives, assuming that cArr
is allocated in C memory.  That said, it's easy to avoid them by
writing code like

q := unsafe.Pointer(cArr)
for i := 0; i < arrLength; i++ {
p := (*Tag)(q)
ret = append(ret, int(*p))
q = unsafe.Pointer(uintptr(q) + unsafe.Sizeof(q))
}

The point is: always keep pointers as pointers, except in expressions
that convert to uintptr and back in a single expression.

Ian

-- 
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.


[go-nuts] Cgo Pointer Arithmetic

2016-08-31 Thread Luke Mauldin
I have questions about pointer arithmetic illustrated by this Play 
example:  https://play.golang.org/p/-cZteTY_M2

Questions:
1) Is this the best way to do pointer arithmetic in Go to process a C array 
and convert it to a Go slice?
2) Go vet gives an error on line 18 but doesn't give much information on 
how to fix the usage of unsafe.Pointer.  Any recommendations?


-- 
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] Compiler plugins or something?

2016-08-31 Thread 'Samuel Tan' via golang-nuts
Got it. Thanks for the quick follow-up, Ian.

On Wed, Aug 31, 2016 at 11:00 AM, Ian Lance Taylor  wrote:

> On Wed, Aug 31, 2016 at 10:31 AM, samueltan via golang-nuts
>  wrote:
> > May I know what the status of compiler plugins are as of Go 1.7? I'm
> hoping
> > to add an additional stage of static checking to the Go compilation
> process,
> > and the only way to do this right now seems to be to write a go vet
> check.
>
> The status is unchanged.  There is no support for compiler plugins and
> no plans for them.  I make no promise that the Go compiler will ever
> support plugins.  I think an external program, along the lines of go
> vet, is the right approach to use for additional static checking.
>
> Ian
>
>
> > On Wednesday, October 7, 2015 at 9:59:26 AM UTC-7, Ian Lance Taylor
> wrote:
> >>
> >> On Wed, Oct 7, 2015 at 8:09 AM, Ilya Kowalewski
> >>  wrote:
> >> > I am asking, cos compiler plugins and related seems like a subject of
> a
> >> > deep
> >> > discussion: some people might not like the whole idea of intervening
> the
> >> > compile process. Even now I can see people complaining about any
> plugin
> >> > functionality. E.g: "you won't be able to compile some software
> straight
> >> > away with go-get if it depends on some compiler plugins" and etc
> >>
> >> I see, sorry.  I was answering about plugins in general, and you are
> >> asking specifically about compiler plugins.  I think we are a long way
> >> from even considering the possibility of compiler plugins.  And I
> >> don't really understand the point of supporting plugins in something
> >> like the Go compiler, which is fast to build and which can in
> >> principle be split up into packages that people can call directly.
> >>
> >> Ian
> >>
> >> > On Wed, 7 Oct 2015 at 17:28 Ian Lance Taylor 
> wrote:
> >> >>
> >> >> On Wed, Oct 7, 2015 at 6:50 AM, Ilya Kowalewski
> >> >>  wrote:
> >> >> > I'd love to, but this seems to be an incredibly complicated
> subject,
> >> >> > which
> >> >> > requires a correponding level of expertise. Is it ok to file a
> >> >> > proposal
> >> >> > /
> >> >> > ask for help or expertise in the meantime?
> >> >>
> >> >> I think people are aware of the issue.  There is a proposed interface
> >> >> at https://golang.org/s/execmodes .  I don't think we need a
> separate
> >> >> proposal or anything.
> >> >>
> >> >> Ian
> >> >
> >> > --
> >> > Talk is cheap. Show me the code.
> >
> > --
> > 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.
>

-- 
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] Compiler plugins or something?

2016-08-31 Thread samueltan via golang-nuts
May I know what the status of compiler plugins are as of Go 1.7? I'm hoping 
to add an additional stage of static checking to the Go compilation 
process, and the only way to do this right now seems to be to write a go 
vet check.

On Wednesday, October 7, 2015 at 9:59:26 AM UTC-7, Ian Lance Taylor wrote:
>
> On Wed, Oct 7, 2015 at 8:09 AM, Ilya Kowalewski 
>  wrote: 
> > I am asking, cos compiler plugins and related seems like a subject of a 
> deep 
> > discussion: some people might not like the whole idea of intervening the 
> > compile process. Even now I can see people complaining about any plugin 
> > functionality. E.g: "you won't be able to compile some software straight 
> > away with go-get if it depends on some compiler plugins" and etc 
>
> I see, sorry.  I was answering about plugins in general, and you are 
> asking specifically about compiler plugins.  I think we are a long way 
> from even considering the possibility of compiler plugins.  And I 
> don't really understand the point of supporting plugins in something 
> like the Go compiler, which is fast to build and which can in 
> principle be split up into packages that people can call directly. 
>
> Ian 
>
> > On Wed, 7 Oct 2015 at 17:28 Ian Lance Taylor  > wrote: 
> >> 
> >> On Wed, Oct 7, 2015 at 6:50 AM, Ilya Kowalewski 
> >>  wrote: 
> >> > I'd love to, but this seems to be an incredibly complicated subject, 
> >> > which 
> >> > requires a correponding level of expertise. Is it ok to file a 
> proposal 
> >> > / 
> >> > ask for help or expertise in the meantime? 
> >> 
> >> I think people are aware of the issue.  There is a proposed interface 
> >> at https://golang.org/s/execmodes .  I don't think we need a separate 
> >> proposal or anything. 
> >> 
> >> Ian 
> > 
> > -- 
> > Talk is cheap. Show me the code. 
>

-- 
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.


[go-nuts] What is the difference between fmt.Print and rand.Intn functions here?

2016-08-31 Thread T L

Why does the parameter passed to fmt.Print escape to heap?


// 11.go
package main
import "fmt"
import "math/rand"

func f1(v int) {
fmt.Print(v) // v escapes to heap
}

var a int
func f2(v int) {
a = rand.Intn(v) // v doesn't escape
}

func main() {
}

/*
> go build -gcflags=-m 11.go
# command-line-arguments
./11.go:15: can inline main
./11.go:7: v escapes to heap
./11.go:7: f1 ... argument does not escape
*/


-- 
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.


[go-nuts] Unable to Get SID in golang

2016-08-31 Thread kumargv
I am getting SID of my system using WMI

>wmic useraccount where name='vijay' get sid
SID
S-1-5-21-742204146-2006990925-2362806598-1001

But still i am not able to get sid structure .

package main

import (
"fmt"
"golang.org/x/sys/windows"
)

func main() {

sid , domain, accType , err := windows.LookupSID("VTHLPT022","vijay")
fmt.Println("sid:",sid)
fmt.Println("domain:",domain)
fmt.Println("accType:",accType)
fmt.Println("err",err)

sids, er:= 
windows.StringToSid("S-1-5-21-742204146-2006990925-2362806598-1001")
fmt.Println("er",er)
fmt.Println("sids : ",sids)
}

output:
sid: &{}
domain: VTHLPT022
accType: 1
err 
er 
sids :  &{}




-- 
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] About runtime.globrunqput/globrunqputhead

2016-08-31 Thread Ian Lance Taylor
On Tue, Aug 30, 2016 at 10:19 PM, Lin Hao  wrote:

>
> I'm reading the runtime code, and there are some questions, as shown below:
>
> func globrunqput(gp *g) {
> gp.schedlink = 0
> if sched.runqtail != 0 {
> sched.runqtail.ptr().schedlink.set(gp)// My question: why?
>
> // I feel should be gp.schedlink.set(sched.runqtail.ptr()) .
>
> // So, the chain is: sched.runqtail => old sched.runqtail.
>
> // I don't know if it's right (like sched.midle, single linked list).
>


To be honest I don't understand your suggestion.  The singly-linked list
starts at sched.runqhead, goes through the schedlink pointers of each G on
the list, and ends at sched.runqtail.  Caling
gp.schedlink.set(sched.runqtail.ptr()) won't put gp on the list.



> } else {
> sched.runqhead.set(gp)// My question: why?
>
> // Set here the head, and then set the tail.
>

That is exactly what this code does: sets the head, and then the next line
sets the fail.


> }
> sched.runqtail.set(gp)
> sched.runqsize++
> }
>
> func globrunqputhead(gp *g) {
> gp.schedlink = sched.runqhead
> sched.runqhead.set(gp)
> if sched.runqtail == 0 {
> sched.runqtail.set(gp)// My question: why?
>
> // Set the head, and then set the tail in here.
> }
> sched.runqsize++
> }
>
>
> Who can answer my question? I'm overwhelmed with gratitude.
>

I think you need to express your questions more clearly, as right now I
don't understand them.

Ian

-- 
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.


[go-nuts] Re: bytes.Buffer and bufio.Reader are no seekers?

2016-08-31 Thread Guillaume LE STUM
I just ran into this as well, when buffering an io.ReadSeeker such as 
os.File it would be useful to have a bufio.ReadSeeker.
I could work around it by calling Seek on the source os.File and using 
bufio.Reader.Reset(...) but this is wasteful when seeked data is already 
buffered

On Thursday, May 2, 2013 at 7:15:52 AM UTC-7, Ingo Oeser wrote:
>
> Hi there,
>
> is there any reason the in-memory streams bytes.Buffer and bufio.Reader 
> support no Seek()?
>
> Just wondered about it, because it would be very handy for unit tests and 
> benchmarks mocking out file system accesses.
>
> So I did sth. like this to test it:
>
>
> http://play.golang.org/p/8SjYn-cisj
>
> package main
>
> import (
> "bytes"
> "fmt"
> "io"
> "os"
> )
>
> type SeekingBuffer struct {
> b  []byte
> buffer *bytes.Buffer
> offset int64
> size   int64
> }
>
> func NewSeekingBuffer(b []byte) *SeekingBuffer {
> if b == nil {
> return nil
> }
> return {
> b:  b,
> buffer: bytes.NewBuffer(b),
> offset: 0,
> }
> }
>
> func (fb *SeekingBuffer) Read(p []byte) (n int, err error) {
> n, err = fb.buffer.Read(p)
> fb.offset += int64(n)
> return n, err
> }
>
> func (fb *SeekingBuffer) Seek(offset int64, whence int) (ret int64, err 
> error) {
> var newoffset int64
> switch whence {
> case 0:
> newoffset = offset
> case 1:
> newoffset = fb.offset + offset
> case 2:
> newoffset = int64(len(fb.b)) - offset
> }
> if newoffset == fb.offset {
> return newoffset, nil
> }
> fb.buffer = bytes.NewBuffer(fb.b[newoffset:])
> fb.offset = newoffset
> return fb.offset, nil
> }
>
> func main() {
> fb := NewSeekingBuffer([]byte("Hello, playground"))
> pos, err := fb.Seek(0, 0)
> fmt.Println("pos = ", pos, ", error = ", err)
> pos, err = fb.Seek(7, 0)
> fmt.Println("pos = ", pos, ", error = ", err)
> io.Copy(os.Stdout, fb)
>
> }
>

-- 
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.


[go-nuts] About runtime.globrunqput/globrunqputhead

2016-08-31 Thread Lin Hao
Hi, all:

I'm reading the runtime code, and there are some questions, as shown below:

func globrunqput(gp *g) {
gp.schedlink = 0
if sched.runqtail != 0 {
sched.runqtail.ptr().schedlink.set(gp)// My question: why? 

  // I feel should be gp.schedlink.set(sched.runqtail.ptr()) .

  // So, the chain is: sched.runqtail => old sched.runqtail.

  // I don't know if it's right (like sched.midle, single linked list).
} else {
sched.runqhead.set(gp)// My question: why?

  // Set here the head, and then set the tail.
}
sched.runqtail.set(gp)
sched.runqsize++
}

func globrunqputhead(gp *g) {
gp.schedlink = sched.runqhead
sched.runqhead.set(gp)
if sched.runqtail == 0 {
sched.runqtail.set(gp)// My question: why?

  // Set the head, and then set the tail in here.
}
sched.runqsize++
}


Who can answer my question? I'm overwhelmed with gratitude. 

-- 
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.


[go-nuts] Close a reader to quit a loop without closing its source

2016-08-31 Thread Dave Cheney
Unfortunately POSIX does not guarantee that close from one thread will unblock 
another. 

-- 
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] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-31 Thread Harald Weidner
Hello,

On Tue, Aug 30, 2016 at 04:41:29PM -0700, 'Eric Johnson' via golang-nuts wrote:

> I looked at the k-nucleotide program, and was unable to figure out a way to
> make it faster.

> This is, of course, exactly what the test is suppose to be checking - the
> speed of the built in map. Anyone else have any insight?

The Java counterpart of this benchmark does not use the Java build-in
maps, but imports a map implementation for fixed data types from the
fastutil project.

http://fastutil.di.unimi.it/

Those libraries are based on generated source code. I think something
similar could be built for Go.

Harald

-- 
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.


[go-nuts] Re: dynamic frequency ticker

2016-08-31 Thread djadala
https://play.golang.org/p/FMs01ACKJv  ?

Djadala

On Tuesday, August 30, 2016 at 8:46:23 PM UTC+3, seb@gmail.com wrote:
>
> In my application I select on a ticker channel, but sometimes need to have 
> the waiting time vary a bit. For not so frequent changes I could make a new 
> ticker everytime, but I have the feeling this is not the best solution for 
> higher frequencies and many rate changes. Best would be if I could tell my 
> existing ticker "from next tick on please use an interval of x". In fact 
> what I want is that the frequency changes over time.
>
> Any tips how to achieve that?
>

-- 
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.