Caleb Spare | 29 Aug 19:52 2015
Picon

asm newbie questions

I'm trying to figure out a problem with an asm function I'm writing.
(I haven't written much assembly, as my many questions should make
abundantly clear.) This is a minimal example: it's a function which
tries to left-shift 1 by the input uint64 and return the result:

// func SHLTest(x uint64) uint64
TEXT ·SHLTest(SB),NOSPLIT,$0-16
    MOVQ  x+0(FP), BX
    MOVQ  $1, R10
    SHLQ  BX, R10
    MOVQ  R10, ret+8(FP)
    RET

The assembler rejects this with a somewhat cryptic (to me) error:

asm: doasm: notfound ft=20 tt=16 00016 (.../instr_amd64.s:75)
SHLQ    BX, R10 20 16

Okay, so I go read the intel x64 manual a bit. I notice that the SHL
instruction operates on a doubleword so it can only shift by up to 31
positions. So maybe the problem is that it's possible for R10 to
contain larger values? I also see that perhaps the PSLLQ instruction
is what I want, since that one operates on a quadword. I'm not sure
what SHLQ in Go asm actually signifies. In
src/cmd/internal/obj/x86/a.out.go I see that PSLLQ is also defined;
replacing SHLQ with PSLLQ in the above function yields the same error
with s/SHLQ/PSLLQ.

Next I try inspecting compiler output. I compile this function with -gcflags -S:

(Continue reading)

Jordan Wright | 29 Aug 04:09 2015
Picon

Buffer vs. bytes.NewReader vs. bufio.NewReader?

Pardon the newbie question, but I'm having some difficulty grasping the idea of effective I/O.

In general, I get the idea of everything being just a stream of bytes to be manipulated, read, written, etc. As to how to do that effectively is what's avoiding me.

Is there a list of best practices on how to effectively use buffers vs. readers/writers?

When should I use bytes.NewReader instead of bufio.NewReader?

Is the only benefit of using a bytes.Buffer to be able to treat the underlying slice dynamically? 

Why would I want to use a bytes.Reader instead of a bytes.Buffer?

Quite a few questions, but any help at all would be greatly appreciated! I feel that the design idioms of Go are almost too elegant and straightforward that I'm missing something!

Thanks in advance,
Jordan

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
timinganalyzer | 28 Aug 16:18 2015
Picon

go for CAD


Hi All,

I'm considering converting a CAD program written in Java,  SWING(GUI), and Jython(user scripting) to go. As a go newbie,  I'm not sure what packages could be used to replace the functionality in the original program. I see some go GUI packages are currently being developed so I could output the CAD drawings to image or SVG files initially and then add GUI functionality in the future.

Some requirements:
  • User scripting (currently Jython,  but would prefer standard Python.   Also would consider other go alternatives)
  • Text File I/O (currently xml similar format,  but would prefer JSON)
  • Image File outputs ( png, gif, etc...)
  • Scalable Vector File output (SVG, PDF)
  • GUI ( can be added later.  Mouse point and click to draw diagrams and keyboard event handling for command inputs)

Is go a good choice for CAD software development and my requirements?    

     
Thanks in advance for your advice.
Dan
      

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
kshrier | 29 Aug 00:21 2015

x/sys/unix: problem adding code to support fgetattr function on solaris

I am writing a Go wrapper around the fgetattr function and I am running into a problem getting it to compile.  I have the same problem using Go 1.5 or Go built from the latest pull of the master branch.  In the following, I will use the setup I have for running with the latest master build.

I am running on omnios 151015
I have the following environment variables exported:

    GOARCH=amd64
    GOOS=solaris
    GOPATH=$HOME/go_stuff/sub_repos/go_master
    GOROOT=/usr/local/go_master

    PATH=/usr/local/go_master/bin:/opt/gcc-5.1.0/bin:/opt/omni/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin

I have the x/sys repo in $HOME/go_stuff/sub_repos/go_master/src/golang.org/x/sys.  When I cd into $HOME/go_stuff/sub_repos/go_master/src/golang.org/x/sys/unix and run "go test", everything works fine.

    $ go test
    PASS
    ok golang.org/x/sys/unix 0.008s

I have added a file named attr_solaris.go in x/sys/unix that just contains the following lines:

    // +build amd64,solaris


    package unix


    /*

    */

    import "C"


Running "go test" now results in the following error:

    $ go test

    # golang.org/x/sys/unix

    ./asm.s: Assembler messages:

    ./asm.s:9: Error: no such instruction: `text ·use(SB),NOSPLIT,$0'

    FAIL    golang.org/x/sys/unix [build failed]


When I look at x/sys/unix/asm.s, line 9 is slightly different from what is in the error message


    TEXT ·use(SB),NOSPLIT,$0


I don't know why the error message has "text" in lower case when the source file has it in upper case.  I have tried specifying -v -x and -work in order to see what might be happening.


    $ go test -v -x -work

    WORK=/tmp/go-build126758309

    mkdir -p $WORK/golang.org/x/sys/unix/_test/golang.org/x/sys/

    mkdir -p $WORK/golang.org/x/sys/unix/_test/_obj_test/

    cd /export/home/kim/go_stuff/sub_repos/go_master/src/golang.org/x/sys/unix

    CGO_LDFLAGS="-g" "-O2" /usr/local/go_master/pkg/tool/solaris_amd64/cgo -objdir $WORK/golang.org/x/sys/unix/_test/_obj_test/ -importpath golang.org/x/sys/unix -- -I $WORK/golang.org/x/sys/unix/_test/_obj_test/ attr_solaris.go

    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -print-libgcc-file-name

    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/golang.org/x/sys/unix/_test/_obj_test/ -g -O2 -o $WORK/golang.org/x/sys/unix/_test/_obj_test/_cgo_main.o -c $WORK/golang.org/x/sys/unix/_test/_obj_test/_cgo_main.c

    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/golang.org/x/sys/unix/_test/_obj_test/ -g -O2 -o $WORK/golang.org/x/sys/unix/_test/_obj_test/_cgo_export.o -c $WORK/golang.org/x/sys/unix/_test/_obj_test/_cgo_export.c

    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/golang.org/x/sys/unix/_test/_obj_test/ -g -O2 -o $WORK/golang.org/x/sys/unix/_test/_obj_test/attr_solaris.cgo2.o -c $WORK/golang.org/x/sys/unix/_test/_obj_test/attr_solaris.cgo2.c

    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/golang.org/x/sys/unix/_test/_obj_test/ -g -O2 -o $WORK/golang.org/x/sys/unix/_test/_obj_test/asm.o -c ./asm.s

    # golang.org/x/sys/unix

    ./asm.s: Assembler messages:

    ./asm.s:9: Error: no such instruction: `text ·use(SB),NOSPLIT,$0'

    $WORK/golang.org/x/sys/unix/_test/unix.test -test.v=true

    FAIL    golang.org/x/sys/unix [build failed]


It appears to be using the asm.s file that already exists in x/sys/unix and not using a generated one so I am at a loss as to why the case of "text" is not upper case.


I actually had some Go code in attr_solaris.go originally and it showed the exact same symptoms.  I have reduced the code to the smallest sample that still shows the problem.


Am I doing something wrong or is there a bug in the toolchain?


Kim

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
martseniuk | 28 Aug 21:24 2015
Picon

[ANN] gomilestone sample

gomilestone.go I hope it save your time when you work with issues & milestones on github.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Jérôme LAFORGE | 28 Aug 19:21 2015
Picon

Go Data Structures: Interfaces

Hello,
According to Russ Cox's post (http://research.swtch.com/interfaces), there are two camps for managing Interface Values:
1 - C++ and Java: tables for all method calls statically
2 - Smalltalk and its many imitators: a method lookup at each call


According to this post, Golang take halfway between these two camps, that is method tables computes at run time.
The advantage of this uncommon method compared to 2nd (i.e. method lookup at each call like Smalltalk and its many imitators) is pretty clear to me (on performance on each call because there is no method lookup).

But, I don't see advantage of this uncommon method compared to 1st (i.e. method tables for all method calls statically like C++ and Java).
Could you list some advantages if exist?


Thank in advance
Best
Jérôme

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
David Walther | 28 Aug 18:50 2015

what are the syscall.Syscall undocumented return values for?

I'm doing windows programming, ended up having to use NewLazyDLL because import
"C" compiles but doesn't run.  It comes down to syscall.Syscall, which isn't
clear.

syscall.Syscall returns (r1, r2 uintptr, err error).  But a C function only
returns 1 value, not 2.  So, what is the difference between r1 and r2?  When am
I interested in one and not the other?  I see in examples that generally the
first value is used.

I'm porting some FFI code in a dynamic language, over to Go.

David

--

-- 
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+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

Tim K | 28 Aug 18:37 2015
Picon

go1.5 vendoring experiment -- what tools work well with it?

What tools do you find useful with the experimental vendoring support in Go 1.5? Things like godep, etc. that can compliment vendoring support and that work well with it.
Or do you do it all by hand?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Diego Stamigni | 28 Aug 14:21 2015
Picon

gomobile bind panic on type struct

Hi guyz, 

I'm getting this strange panic while trying to use gomobile bind in a little library that I'm writing. 
It's mainly an experiment, but I'm not sure if this kind of stack trace could be related to a bug in my code or something else.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
wangcong268 | 28 Aug 07:54 2015
Picon

compile go1.5 source code failed.

i clone the newest go 1.5 source code from github [16cf8802f87de8738a585d7cd46a388e2afc9388],but when i use go1.4 to compile it,it stopped at 
##### building go bootstrap tool
cmd/dist


waiting for a long time always this status.

My platform is amd64 win10 64bit.


someone who has this issues?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Joseph Mathew | 28 Aug 07:03 2015
Picon

Raspberry Pi Go 1.5 compile test failure

Appreciate help related to test for Go 1.5 compile failure on Raspberry Pi 2. How to narrow this failure to a specific feature of Go 1.5?
Note the compilation for 1.4.2 on Raspberry Pi 2 completed correctly including testing.

The test failure was on goroutine for Go1.5 (got a large printout saying timeout and goroutine runnable locked to thread)
How can I run specific test for goroutine using go test?
Thanks for showing me a direction for testing.
Joseph Mathew
(beginner on Go)

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane