Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-09-01 Thread Shane
Does that mean it is not possible to cross-compile Go for a Solaris target 
on a Linux host until one or both of those issues have been fixed?

On Thursday, September 1, 2022 at 4:11:16 AM UTC-4 se...@liao.dev wrote:

> That's a known issue, see:
> https://go.dev/issue/53813
> https://go.dev/issue/54197
>
>
> - sean
>
> On Wed, Aug 31, 2022, 21:35 Shane  wrote:
>
>> I was finally able to compile the bootstrap on Linux (I had to install 
>> the missing libc).
>>
>> However, after copying the .tbz file onto my Solaris 11u4 AMD64 machine 
>> to build the final Go tools, building fails:
>>
>> $ GOROOT_BOOTSTRAP=/tmp/bootstap-goroot CGO_ENABLED=1 ./all.bash
>> Building Go cmd/dist using /tmp/bootstap-goroot. (go1.19 solaris/amd64)
>> dist: Cannot find /lib64/ld-linux-x86-64.so.2
>>
>> Why does the bootstrap go expect /lib64/ld-linux-x86-64.so.2? Shouldn't 
>> it only be looking for Solaris libs?
>> On Saturday, August 27, 2022 at 3:18:42 PM UTC-4 Ian Lance Taylor wrote:
>>
>>> On Sat, Aug 27, 2022 at 12:15 PM Shane  wrote: 
>>> > 
>>> > My understanding then is that cmd/dist first builds for the host here 
>>> (in my case, for Linux) and then builds for the target starting here. Since 
>>> there is always a build for the host first, then since my host OS is Linux, 
>>> the linux_syscall.c is always part of the compilation (since I do not 
>>> disable cgo). If anything is incorrect with my understanding, please 
>>> correct me. 
>>> > 
>>> > I believe then I need to have both Linux system headers and Solaris 
>>> system headers available on my build machine for the cross-compile, if I 
>>> want to build Go for Solaris with cgo support. 
>>> > 
>>> > Is it possible for there to be two header files with the same name but 
>>> different OS have the same #include path in the cgo source code? If so, 
>>> could the C compiler get the correct header for the target of the cgo? For 
>>> example, how could the C compiler know to use the Linux unistd.h header for 
>>> the Linux build, and later use the Solaris unistd.h header for the Solaris 
>>> build? 
>>>
>>> I'm not sure whether this answers your question, but normally a system 
>>> will have a native compiler that will look for header files in 
>>> /usr/include. It can also have a cross-compiler that looks for header 
>>> files in some other location. A cross-compiler should never look in 
>>> /usr/include, it should only look at the cross-compilation header 
>>> files. 
>>>
>>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/6dd9a30f-d4be-45ff-a80c-499a71933259n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/6dd9a30f-d4be-45ff-a80c-499a71933259n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7ffc15cc-3313-4d3c-be28-16201c7dbf49n%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-31 Thread Shane
I was finally able to compile the bootstrap on Linux (I had to install the 
missing libc).

However, after copying the .tbz file onto my Solaris 11u4 AMD64 machine to 
build the final Go tools, building fails:

$ GOROOT_BOOTSTRAP=/tmp/bootstap-goroot CGO_ENABLED=1 ./all.bash
Building Go cmd/dist using /tmp/bootstap-goroot. (go1.19 solaris/amd64)
dist: Cannot find /lib64/ld-linux-x86-64.so.2

Why does the bootstrap go expect /lib64/ld-linux-x86-64.so.2? Shouldn't it 
only be looking for Solaris libs?
On Saturday, August 27, 2022 at 3:18:42 PM UTC-4 Ian Lance Taylor wrote:

> On Sat, Aug 27, 2022 at 12:15 PM Shane  wrote:
> >
> > My understanding then is that cmd/dist first builds for the host here 
> (in my case, for Linux) and then builds for the target starting here. Since 
> there is always a build for the host first, then since my host OS is Linux, 
> the linux_syscall.c is always part of the compilation (since I do not 
> disable cgo). If anything is incorrect with my understanding, please 
> correct me.
> >
> > I believe then I need to have both Linux system headers and Solaris 
> system headers available on my build machine for the cross-compile, if I 
> want to build Go for Solaris with cgo support.
> >
> > Is it possible for there to be two header files with the same name but 
> different OS have the same #include path in the cgo source code? If so, 
> could the C compiler get the correct header for the target of the cgo? For 
> example, how could the C compiler know to use the Linux unistd.h header for 
> the Linux build, and later use the Solaris unistd.h header for the Solaris 
> build?
>
> I'm not sure whether this answers your question, but normally a system
> will have a native compiler that will look for header files in
> /usr/include. It can also have a cross-compiler that looks for header
> files in some other location. A cross-compiler should never look in
> /usr/include, it should only look at the cross-compilation header
> files.
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6dd9a30f-d4be-45ff-a80c-499a71933259n%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
Ah, I see now, sorry for not noticing that.

My understanding then is that cmd/dist first builds for the host here 
<https://go.googlesource.com/go/+/refs/tags/go1.19/src/cmd/dist/build.go#1411> 
(in my case, for Linux) and then builds for the target starting here 
<https://go.googlesource.com/go/+/refs/tags/go1.19/src/cmd/dist/build.go#1432>. 
Since there is always a build for the host first, then since my host OS is 
Linux, the linux_syscall.c is always part of the compilation (since I do 
not disable cgo). If anything is incorrect with my understanding, please 
correct me.

I believe then I need to have both Linux system headers and Solaris system 
headers available on my build machine for the cross-compile, if I want to 
build Go for Solaris with cgo support.

Is it possible for there to be two header files with the same name but 
different OS have the same #include path in the cgo source code? If so, 
could the C compiler get the correct header for the target of the cgo? For 
example, how could the C compiler know to use the Linux unistd.h header for 
the Linux build, and later use the Solaris unistd.h header for the Solaris 
build?

On Saturday, August 27, 2022 at 2:59:31 PM UTC-4 se...@liao.dev wrote:

> make.bash calls cmd/dist which does the build chaining, calling it 
> directly doesn't skip the process.
>
> - sean
>
> On Sat, Aug 27, 2022, 19:54 Shane  wrote:
>
>> >  Is there some way I can skip straight to building Go for my Solaris 
>> target using my existing Linux Go tools?
>> Sorry, this question was foolish. Of course I can skip straight to 
>> building for Solaris, by using the make.bash script.
>>
>> But as I pointed out earlier,
>> > I looked at the POSIX docs 
>> <https://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html>, 
>> and POSIX only has a setregid() 
>> <https://pubs.opengroup.org/onlinepubs/9699919799/functions/setregid.html> 
>> function, 
>> and not a setresgid() <https://linux.die.net/man/2/setresgid> function.
>>
>> And
>> >  make.bash runs go build with the GOOS and GOARCH set to empty strings 
>> here 
>> <https://go.googlesource.com/go/+/refs/tags/go1.19/src/make.bash#201>.
>>
>> Please correct me if I am wrong, but my assumption is that if GOOS was 
>> properly set to solaris by make.bash, then linux_syscall.c would not be 
>> compiled, and then I would not get the compiler error I am seeing.
>>
>> On Saturday, August 27, 2022 at 2:40:52 PM UTC-4 Shane wrote:
>>
>>> I already have a working Go 1.19 for Linux with cgo support on my build 
>>> machine that I downloaded and installed from https://go.dev. Given 
>>> this, is it still necessary to build for the host? Is there some way I can 
>>> skip straight to building Go for my Solaris target using my existing Linux 
>>> Go tools? Or if I do that, does that break the guarantee of a consistent 
>>> final artifact?
>>
>> -- 
>>
> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/599210f2-ec20-4928-8d9c-89e1d56041b8n%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
>  Is there some way I can skip straight to building Go for my Solaris 
target using my existing Linux Go tools?
Sorry, this question was foolish. Of course I can skip straight to building 
for Solaris, by using the make.bash script.

But as I pointed out earlier,
> I looked at the POSIX docs 
<https://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html>, and 
POSIX only has a setregid() 
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/setregid.html> 
function, 
and not a setresgid() <https://linux.die.net/man/2/setresgid> function.

And
>  make.bash runs go build with the GOOS and GOARCH set to empty strings 
here <https://go.googlesource.com/go/+/refs/tags/go1.19/src/make.bash#201>.

Please correct me if I am wrong, but my assumption is that if GOOS was 
properly set to solaris by make.bash, then linux_syscall.c would not be 
compiled, and then I would not get the compiler error I am seeing.

On Saturday, August 27, 2022 at 2:40:52 PM UTC-4 Shane wrote:

> I already have a working Go 1.19 for Linux with cgo support on my build 
> machine that I downloaded and installed from https://go.dev. Given this, 
> is it still necessary to build for the host? Is there some way I can skip 
> straight to building Go for my Solaris target using my existing Linux Go 
> tools? Or if I do that, does that break the guarantee of a consistent final 
> artifact?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
I already have a working Go 1.19 for Linux with cgo support on my build 
machine that I downloaded and installed from https://go.dev. Given this, is 
it still necessary to build for the host? Is there some way I can skip 
straight to building Go for my Solaris target using my existing Linux Go 
tools? Or if I do that, does that break the guarantee of a consistent final 
artifact?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b8adfc70-db5c-48c1-b0d4-e0dd88e8382cn%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
I noticed bootstrap.bash just calls make.bash here 
<https://go.googlesource.com/go/+/refs/tags/go1.19/src/bootstrap.bash#61>, 
and make.bash runs go build with the GOOS and GOARCH set to empty strings 
here <https://go.googlesource.com/go/+/refs/heads/master/src/make.bash#195>.

Does this mean that whatever I set for GOOS when I run either boostrap.bash 
or make.bash is always ignored?

On Saturday, August 27, 2022 at 12:53:48 PM UTC-4 Brian Candler wrote:

> On Saturday, 27 August 2022 at 17:10:21 UTC+1 Shane wrote:
>
>> Is it expected that linux_syscall.c would be compiled when the GOOS 
>> environment variable is set to solaris?
>
>
> I see the log output does include this line:
>
> Building packages and commands for host, linux/amd64.
>
> Although I'm not sure why it couldn't use the existing toolchain directly.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d797bdf4-e0c8-4096-a54d-be792ed50a90n%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-19 Thread Shane
Compiling with the boostrap.bash script also fails:

$ GOOS=solaris GOARCH=amd64 ./bootstrap.bash
 Copying to ../../go-solaris-amd64-bootstrap

 Cleaning ../../go-solaris-amd64-bootstrap
Removing src@tmp/

 Building ../../go-solaris-amd64-bootstrap

Building Go cmd/dist using /usr/local/go. (go1.19 linux/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for host, linux/amd64.
# runtime/cgo
linux_syscall.c: In function '_cgo_libc_setresgid':
linux_syscall.c:67:2: error: implicit declaration of function 'setresgid' 
[-Werror=implicit-function-declaration]
linux_syscall.c: In function '_cgo_libc_setresuid':
linux_syscall.c:73:2: error: implicit declaration of function 'setresuid' 
[-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
go tool dist: FAILED: 
/builds/workspace/developer/Prime/Bishop/go/go-solaris-amd64-bootstrap/pkg/tool/linux_amd64/go_bootstrap
 
install std cmd: exit status 2

I have multiple libc* files on my build machine. Of the ones that are not 
symlinks, I 
have /lib/x86_64-linux-gnu/libc-2.28.so, /sysroot/lib/amd64/libc.so.1, 
and /sysroot/lib/libc.so.1. So I think I have glibc 2.28 based on the first 
file, but I am not certain. My gcc is gcc 4.7.4.

I have multiple unistd.h files on my build machine, but none of them have 
setresgid (I checked by running find as root to find all the unistd.h 
files, and then I grepped each of them for setresgid).

Is there a minimum libc version that is needed to compile the boostrap?
On Thursday, August 18, 2022 at 10:52:47 PM UTC-4 Ian Lance Taylor wrote:

> On Thu, Aug 18, 2022 at 5:05 PM Shane  wrote:
> >
> > I'm not sure what you mean when you ask which C library version I am 
> using. Are you asking the version of my libc?
> >
> > I am cross-compiling on Debian 10 using Go 1.19 and gcc 4.7.4 (but my 
> understanding is that a C compiler is only used for the cgo parts of the Go 
> source tree, and that most of the Go source tree is compiled by Go). My 
> target is Solaris 11.
>
> I'm wondering why it appears that setresgid is not declared on your
> system. So I am asking which libc you are using, and what version it
> is. For example, on my system setresgid is declared in ; I
> am running glibc 2.33.
>
> But that is likely a side issue. To build a Go distribution for
> Solaris, use the bootstrap.bash script that I mentioned.
>
> Ian
>
>
> > On Wednesday, August 17, 2022 at 10:16:10 PM UTC-4 Ian Lance Taylor 
> wrote:
> >>
> >> On Wed, Aug 17, 2022 at 4:28 PM Shane  wrote:
> >> >
> >> > I am trying to follow what I believe to be the official instructions 
> for building Go from source. (I am not trying to build my own Go code, I am 
> trying to build the Go project itself.)
> >> >
> >> > The reason I want to do this is to build a Go 1.19 compiler for 
> Solaris, since there are no prebuilt Go 1.19 binaries for Solaris available 
> on the Go downloads page.
> >> >
> >> > On the official instructions page, under the "Optional environment 
> variables" section, it says "The Go compilation environment can be 
> customized by environment variables."
> >> >
> >> > Later in this same section, it then says that the GOOS and GOARCH 
> environment variables can be used to set the target operating system and 
> compilation architecture.
> >> >
> >> > I tried building like this, after cloning the source code and 
> checking out the go1.19 tag, but the build fails:
> >> >
> >> > $ GOOS=solaris GOARCH=amd64 GOROOT_FINAL=../publish ./all.bash
> >> > Building Go cmd/dist using /usr/local/go. (go1.19 linux/amd64)
> >> > Building Go toolchain1 using /usr/local/go.
> >> > Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
> >> > Building Go toolchain2 using go_bootstrap and Go toolchain1.
> >> > Building Go toolchain3 using go_bootstrap and Go toolchain2.
> >> > Building packages and commands for host, linux/amd64.
> >> > # runtime/cgo
> >> > linux_syscall.c: In function '_cgo_libc_setresgid':
> >> > linux_syscall.c:67:2: error: implicit declaration of function 
> 'setresgid' [-Werror=implicit-function-declaration]
> >> > linux_syscall.c: In function '_cgo_libc_setresuid':
> >> > linux_syscall.c:73:2: error: implicit declaration of function 
> 'setresuid' [-Werror=implicit-function-declaration]
> >> > cc1: all warnings being treated as errors
> >> &

Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-18 Thread Shane
I'm not sure what you mean when you ask which C library version I am using. 
Are you asking the version of my libc?

I am cross-compiling on Debian 10 using Go 1.19 and gcc 4.7.4 (but my 
understanding is that a C compiler is only used for the cgo parts of the Go 
source tree, and that most of the Go source tree is compiled by Go). My 
target is Solaris 11.
On Wednesday, August 17, 2022 at 10:16:10 PM UTC-4 Ian Lance Taylor wrote:

> On Wed, Aug 17, 2022 at 4:28 PM Shane  wrote:
> >
> > I am trying to follow what I believe to be the official instructions for 
> building Go from source. (I am not trying to build my own Go code, I am 
> trying to build the Go project itself.)
> >
> > The reason I want to do this is to build a Go 1.19 compiler for Solaris, 
> since there are no prebuilt Go 1.19 binaries for Solaris available on the 
> Go downloads page.
> >
> > On the official instructions page, under the "Optional environment 
> variables" section, it says "The Go compilation environment can be 
> customized by environment variables."
> >
> > Later in this same section, it then says that the GOOS and GOARCH 
> environment variables can be used to set the target operating system and 
> compilation architecture.
> >
> > I tried building like this, after cloning the source code and checking 
> out the go1.19 tag, but the build fails:
> >
> > $ GOOS=solaris GOARCH=amd64 GOROOT_FINAL=../publish ./all.bash
> > Building Go cmd/dist using /usr/local/go. (go1.19 linux/amd64)
> > Building Go toolchain1 using /usr/local/go.
> > Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
> > Building Go toolchain2 using go_bootstrap and Go toolchain1.
> > Building Go toolchain3 using go_bootstrap and Go toolchain2.
> > Building packages and commands for host, linux/amd64.
> > # runtime/cgo
> > linux_syscall.c: In function '_cgo_libc_setresgid':
> > linux_syscall.c:67:2: error: implicit declaration of function 
> 'setresgid' [-Werror=implicit-function-declaration]
> > linux_syscall.c: In function '_cgo_libc_setresuid':
> > linux_syscall.c:73:2: error: implicit declaration of function 
> 'setresuid' [-Werror=implicit-function-declaration]
> > cc1: all warnings being treated as errors
> > go tool dist: FAILED: 
> /some/redacted/parent/dirs/go/goroot/pkg/tool/linux_amd64/go_bootstrap 
> install std cmd: exit status 2
> >
> > I am building on Linux. I have gcc and Go 1.19 installed on my Linux 
> system, and both tools are on my PATH.
> >
> > I am looking for help fixing these errors.
>
> See src/bootstrap.bash for a script that can build a toolchain for a
> different target.
>
> That said, that's a strange error. What C library version are you using?
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/84132b4b-64ef-4250-a162-1783cfd559bcn%40googlegroups.com.


[go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-17 Thread Shane
Hi fellow Gophers!
<https://stackoverflow.com/posts/73390578/timeline>

I am trying to follow what I believe to be the official instructions 
<https://go.dev/doc/install/source> for building Go from source. (I am not 
trying to build my own Go code, I am trying to build the Go project itself.)

The reason I want to do this is to build a Go 1.19 compiler for Solaris, 
since there are no prebuilt Go 1.19 binaries for Solaris available on the Go 
downloads page <https://go.dev/dl/>.

On the official instructions page, under the "Optional environment 
variables" section, it says "The Go compilation environment can be 
customized by environment variables."

Later in this same section, it then says that 
the GOOS and GOARCH environment variables can be used to set the target 
operating system and compilation architecture.

I tried building like this, after cloning the source code and checking out 
the go1.19 tag, but the build fails:
$ GOOS=solaris GOARCH=amd64 GOROOT_FINAL=../publish ./all.bash
Building Go cmd/dist using /usr/local/go. (go1.19 linux/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for host, linux/amd64.
# runtime/cgo
linux_syscall.c: In function '_cgo_libc_setresgid':
linux_syscall.c:67:2: error: implicit declaration of function 'setresgid' 
[-Werror=implicit-function-declaration]
linux_syscall.c: In function '_cgo_libc_setresuid':
linux_syscall.c:73:2: error: implicit declaration of function 'setresuid' 
[-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
go tool dist: FAILED: 
/some/redacted/parent/dirs/go/goroot/pkg/tool/linux_amd64/go_bootstrap 
install std cmd: exit status 2

I am building on Linux. I have gcc and Go 1.19 installed on my Linux 
system, and both tools are on my PATH.

I am looking for help fixing these errors.

Best regards,
Shane

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e5905d1d-45cc-4019-827d-1675aa842e69n%40googlegroups.com.


Re: [go-nuts] builtin function definitions

2020-07-29 Thread Shane H


On Wednesday, July 29, 2020 at 7:23:22 PM UTC+10, mb0 wrote:
>
> This is a special kind of switch called a type switch. You can read more 
> about it in the language specification where its part of the intrinsic 
> go syntax. https://golang.org/ref/spec#Switch_statements 
>
> Because it is a special language construct you need to look at the 
> compiler. You probably want to check out the default gc compiler and may 
> start your journey here: 
>
> https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/swt.go#L617
>  
>
> This is really helpful, thanks.

The two questions I am left with are:
How do I recognise that something is a "special language construct"; is it 
simply a matter of, I cannot ctrl-] to it directly, so I need to grep?


And, just as importantly, how do I find out what I need to grep /for/

Regards
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5d2cfcd6-579a-4846-8c33-0aa763a9efd9o%40googlegroups.com.


[go-nuts] Re: builtin function definitions

2020-07-28 Thread Shane H
Hrm, that bpaste site will only last a week, so, for posterity, I'll paste 
the script here

#!/bin/bash if [[ "$#" -ne 1 ]]; then echo "No filename supplied, nothing 
to do" exit 0 fi INFILE="$1" echo "=== In file 
===" cat $INFILE echo 
"" # See assembly 
code generated by compiler echo "= ASM generated in compilation 
=" GOOS=linux GOARCH=amd64 go tool compile -S $INFILE echo 
"" # What's in the 
binary after linking echo " After Linker 
==" go build -o x.exe $INFILE go tool objdump -s 
main.main x.exe echo 
"" echo "Cleaning 
up" rm -i x.exe rm -i $(echo "$INFILE"| sed "s/go$/o/") 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/59001cff-6572-4833-90d8-a690c2087005o%40googlegroups.com.


[go-nuts] Re: builtin function definitions

2020-07-28 Thread Shane H
Thanks, I have a bash script that I use to examine the assembly code that 
is generated by a given go file 
https://bpa.st/MRJ4IWJFJ5YNHXFLCMMYGGSI3A

But that takes me past the code that was used to generate that assembly

I'm wanting the midpoint here, the code that the compiler sees, in order to 
generate the assembly.


On Wednesday, July 29, 2020 at 12:20:17 PM UTC+10, tokers wrote:
>
> You may try to use `go tool compile -S ` and read the assemble 
> codes to find the truth.
>
> On Wednesday, July 29, 2020 at 5:39:53 AM UTC+8 shan...@gmail.com wrote:
>
>> Hi all, I'm trying to understand what *exactly* the .(type) is doing in 
>> the following statement
>>
>> switch foo := bar.(type)
>>
>> I mean, I get that foo is being assigned a type converted version of the 
>> bar interface, but, I want to see what exactly they .(type) call does.
>>
>> I have found 
>> https://github.com/golang/go/blob/master/src/go/types/selection.go#L60 
>> which I *think* is the method being called, but I am not sure.
>>
>> So I have two questions.
>> 1) Am I looking at the correct function
>> 2) (and far more importantly) How do I find which method such code is 
>> calling (it's problematic for me at this point towork out what, for 
>> example, something defined in builtin is really calling.
>>
>> Can someone point me at a resource that I have obviously overlooked?
>>
>>
>> Note: I've seen this 
>> https://stackoverflow.com/questions/18512781/built-in-source-code-location 
>> and, rereading it this morning it looks like "If it's not in the runtime 
>> package, start grepping the compiler packages" - is that what I should be 
>> doing?
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3cc9eb52-ba92-4c80-8b4a-95fd778785ebo%40googlegroups.com.


[go-nuts] builtin function definitions

2020-07-28 Thread Shane H
Hi all, I'm trying to understand what *exactly* the .(type) is doing in the 
following statement

switch foo := bar.(type)

I mean, I get that foo is being assigned a type converted version of the 
bar interface, but, I want to see what exactly they .(type) call does.

I have 
found https://github.com/golang/go/blob/master/src/go/types/selection.go#L60 
which I *think* is the method being called, but I am not sure.

So I have two questions.
1) Am I looking at the correct function
2) (and far more importantly) How do I find which method such code is 
calling (it's problematic for me at this point towork out what, for 
example, something defined in builtin is really calling.

Can someone point me at a resource that I have obviously overlooked?


Note: I've seen 
this https://stackoverflow.com/questions/18512781/built-in-source-code-location 
and, rereading it this morning it looks like "If it's not in the runtime 
package, start grepping the compiler packages" - is that what I should be 
doing?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e52c6dbc-1cb8-44c1-a45b-be93c89bb1b7o%40googlegroups.com.


Re: [go-nuts] Json encoder produces base64

2020-04-06 Thread Shane H
OMG, it was my *test* that was modifying the value... Thanks so much for 
your time

On Monday, April 6, 2020 at 4:24:10 PM UTC+10, Jakob Borg wrote:
>
> Hi Shane, 
>
> This doesn't happen with your example: 
> https://play.golang.org/p/C3zb6Qyx-2f
>
> Can you provide a small example of when it does happen?
>
> //jb
>
> On 6 Apr 2020, at 08:03, Shane H > wrote:
>
> I know that it's documented that the json encoder will produce base64 "Array 
> and slice values encode as JSON arrays, except that []byte encodes as a 
> base64-encoded string", but I am getting a base64 response when I pass in 
> a string
>
> response := []string 
> response = append(response, "
> http://localhost:1/obscured/media/f7/c3/e6/a74f71b64712bf11af31b2d027dadbe41f63313103d14a528043d66173
> ")
>
> w.WriteHeader(http.StatusCreated)
> if err := json.NewEncoder(w).Encode(response); err != nil{
> // handle error
> }
>
> Will produce the base64 equivalent of the URL, instead of json.
>
> Given that every time I have asked for help on this list I have discovered 
> that it's something that I am doing wrong, I do NOT mind if someone 
> helpfully points me toward the documentation I am misreading
>
> -- 
> 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 golan...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/4e145a21-52cb-4393-bda0-b11d11a471ed%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/4e145a21-52cb-4393-bda0-b11d11a471ed%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ed5fba21-594d-4952-9937-c08182d43433%40googlegroups.com.


[go-nuts] Json encoder produces base64

2020-04-06 Thread Shane H
I know that it's documented that the json encoder will produce base64 "Array 
and slice values encode as JSON arrays, except that []byte encodes as a 
base64-encoded string", but I am getting a base64 response when I pass in a 
string

response := []string
response = append(response, 
"http://localhost:1/obscured/media/f7/c3/e6/a74f71b64712bf11af31b2d027dadbe41f63313103d14a528043d66173;)

w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(response); err != nil{
// handle error
}

Will produce the base64 equivalent of the URL, instead of json.

Given that every time I have asked for help on this list I have discovered 
that it's something that I am doing wrong, I do NOT mind if someone 
helpfully points me toward the documentation I am misreading

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4e145a21-52cb-4393-bda0-b11d11a471ed%40googlegroups.com.


Re: [go-nuts] Tests skipping

2020-03-23 Thread Shane H


On Monday, March 23, 2020 at 2:49:46 PM UTC+11, Ian Lance Taylor wrote:
>
> On Sun, Mar 22, 2020 at 7:10 PM Shane H > 
> wrote: 
> > 
> > I'm a lot confused by the behaviour of some tests I have at the moment, 
> they're skipping.. when there's no skip or timeout or... anything that I 
> can see 
> > 
> > I know this is going to be difficult because I don't have code I can 
> paste to show what's happening 
> > 
> > I'm using go1.13.9, but this behaviour was also happening with go1.13.7 
> > 
> > I have tests run from a script with 
> > go test ./... -v -count=1 // Note count=1 was added to try and stop the 
> behaviour 
> > 
> > The tests that I am interested are table tests run inside 
> > for _, testCase := range tt { 
> > testCase := testCase 
> > t,Run(testCase.name, func(t *testing.T) { 
> > res, err := http.DefaultClientDo(testCase.before(t)) 
> > require.NoError(t, err) 
> > defer res.Body.Close() 
> > testCase.check(t, res) 
> > } 
> > } 
> > 
> > When I set two of the tests to time.Sleep(time.Millisecond * 1000) the 
> tests should fail 
> > 
> > Sometimes they do, but sometimes they instead Skip, or even report that 
> they were run, passed, with an updated time (they shouldn't pass) 
> > 
> > Can someone point me in the direction of some helpful (perhaps) 
> documentation if that's what I need to read? 
>
> What do you mean when you say that the tests are skipped?  What is the 
> output of your "go test" command? 
>
> Can you show us a small complete test case that demonstrates the problem? 
>
> Ian 
>

I wish I could (provide a test case), but it only happens on my branch.

The output of the go test is
TestQuoteDate (skipping) // or words to that effect

I'm thinking that it /has/ to be user error, but I cannot see what I'm 
doing that's causing the problem (except making the test sleep so I can 
make the API I am interacting with trigger a bug I am trying to track down)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ba5495e5-5fc3-45f7-a36c-ba54635dc333%40googlegroups.com.


[go-nuts] Tests skipping

2020-03-22 Thread Shane H
I'm a lot confused by the behaviour of some tests I have at the moment, 
they're skipping.. when there's no skip or timeout or... anything that I 
can see

I know this is going to be difficult because I don't have code I can paste 
to show what's happening

I'm using go1.13.9, but this behaviour was also happening with go1.13.7

I have tests run from a script with 
go test ./... -v -count=1 // Note count=1 was added to try and stop the 
behaviour

The tests that I am interested are table tests run inside 
for _, testCase := range tt {
testCase := testCase
t,Run(testCase.name, func(t *testing.T) {
res, err := http.DefaultClientDo(testCase.before(t))
require.NoError(t, err)
defer res.Body.Close()
testCase.check(t, res)
}
}

When I set two of the tests to time.Sleep(time.Millisecond * 1000) the 
tests should fail

Sometimes they do, but sometimes they instead Skip, or even report that 
they were run, passed, with an updated time (they shouldn't pass)

Can someone point me in the direction of some helpful (perhaps) 
documentation if that's what I need to read?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ab7e02e5-2591-4142-a38d-8bb455eae22c%40googlegroups.com.


[go-nuts] Re: Printing *go/ast.CommentGroup

2020-01-26 Thread Shane H


On Sunday, January 26, 2020 at 1:49:15 PM UTC+11, Shane H wrote:
>
> Hi all, I'm trying to learn how to write a linter (because long weekend, 
> etc)
>
> I looked at Fatih's very fine blog post (
> https://arslan.io/2019/06/13/using-go-analysis-to-write-a-custom-linter/) 
> as well as the one that precedes it, although I was a LOT lost reading that 
> one.
>
> Copying and pasting 
> https://github.com/fatih/addlint/blob/master/addcheck/addcheck.go got me 
> started, but the linter I have in mind needs to see strings, a trip to 
> https://golang.org/src/go/token/token.go and 
> https://golang.org/src/go/ast/ast.go showed me the possibilities. This  
> (fortunately?) made me switch priorities slightly, as I now want to write 
> something that is going to print each and every node (and this is where my 
> problems began).
>
> I used Fatih's run and render functions but discovered that an error is 
> being generated for the Doc comment, and I cannot see *why* 
> (ast.CommentGroup is fine in parts of the code.. except for `func (p 
> *printer) printNode(node interface{}) error`
>  (https://golang.org/src/go/printer/printer.go 
> <https://golang.org/src/go/printer/printer.go> line 1073), the format 
> node section (lines 1125 - 1155) take me to the unsupported label, which 
> generates an error
>
> My code (main.go, lencheck.go, and complete output can be found at 
> https://play.golang.org/p/olvJ64EDdKZ, please excuse the length of the 
> paste, I put *everything* in there)
>
> As you can see in my code there are 4 nodes that throw errors, and I don't 
> understand if 1) that is intended or 2) I am doing (or not doing as the 
> case may be) something to cause the issue.
>
>  Any help/pointers appreciated
>

I've ended up writing my own print method, that prints the text for the 
given node. I'm not 100% sure why the format node function is needed for 
certain nodes, but I also realised I could just print the comments out in 
my code fairly easily.

The reason I need to do it is because the first phase of writing my tool is 
'seeing' what the code is seeing, and reacting to.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/86889841-9f6a-46b3-9ff6-9aae231cfdf4%40googlegroups.com.


[go-nuts] Printing *go/ast.CommentGroup

2020-01-25 Thread Shane H
Hi all, I'm trying to learn how to write a linter (because long weekend, 
etc)

I looked at Fatih's very fine blog post (
https://arslan.io/2019/06/13/using-go-analysis-to-write-a-custom-linter/) 
as well as the one that precedes it, although I was a LOT lost reading that 
one.

Copying and pasting 
https://github.com/fatih/addlint/blob/master/addcheck/addcheck.go got me 
started, but the linter I have in mind needs to see strings, a trip to 
https://golang.org/src/go/token/token.go and 
https://golang.org/src/go/ast/ast.go showed me the possibilities. This  
(fortunately?) made me switch priorities slightly, as I now want to write 
something that is going to print each and every node (and this is where my 
problems began).

I used Fatih's run and render functions but discovered that an error is 
being generated for the Doc comment, and I cannot see *why* 
(ast.CommentGroup is fine in parts of the code.. except for `func (p 
*printer) printNode(node interface{}) error`
 (https://golang.org/src/go/printer/printer.go 
 line 1073), the format node 
section (lines 1125 - 1155) take me to the unsupported label, which 
generates an error

My code (main.go, lencheck.go, and complete output can be found 
at https://play.golang.org/p/olvJ64EDdKZ, please excuse the length of the 
paste, I put *everything* in there)

As you can see in my code there are 4 nodes that throw errors, and I don't 
understand if 1) that is intended or 2) I am doing (or not doing as the 
case may be) something to cause the issue.

 Any help/pointers appreciated

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e305e103-c8d1-46e5-816d-87f45ec9b963%40googlegroups.com.


[go-nuts] Re: Mail library supporting Google OAuth for Gmail?

2019-12-27 Thread Shane H


On Saturday, December 28, 2019 at 5:23:27 AM UTC+11, Ignacio Grande wrote:
>
> Hi!
>
> I have an application I made a few years ago for a friend which sends 
> emails using a Gmail account with STMP, using the library 
> gopkg.in/gomail.v1. Since then I moved on and I'm not familiar with 
> latest changes in Gmail or the library.
>
> It seems Google is dropping access for LSA (less secure apps) in June and 
> I've been asked if I can update the apps to work with OAuth. 
>
> I've doing some research and it seems that:
>
>- gomail.v1 moved to gomail.v2, but it was abandoned several years ago.
>- I cannot configure SMTP access in my Gmail account. Has STMP support 
>dropped from Gmail? Current account works, so maybe it is not possible to 
>activate it but accounts already using it works? Do you know if this will 
>last? 
>
> I guess it's time to learn how to use IMAP and OAuth in Go with Gmail to 
> update the app. Can you tell me of any tutorial/library to use? 
>
> Thanks a lot.
>
>
>
So I recently created some code that uses Gmail to send .. mail..
https://developers.google.com/gmail/api/quickstart/go has instructions and 
example (Go) code that you can use. I split the token code off to its own 
standalone pkg so that any code could then use the creds+tokens to send 
emails, without the need to y/n all the time. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/647341a5-e203-4b40-8450-846a2aac1577%40googlegroups.com.


Re: [go-nuts] Unit testing AMQP/build flags for tests

2019-11-18 Thread Shane H


On Tuesday, November 19, 2019 at 4:11:52 PM UTC+11, burak serdar wrote:
>
>
>
> This is what I usually do in these situations: 
>
> var amqpDial=amqp.Dial 
>  func (mq *MQ) Connect() (err error) { 
>   ... 
>mq.conn, err = amqpDial(mq.URI) 
>   ... 
> } 
>
> func TestConnect(t *testing.T) { 
> amqpDial=fakeDial 
> defer func() {amqpDial=amqp.Dial}() 
>... 
> } 
>
>
> This works, the only drawback is that I have to choose between making  
amqpDial an exported (I want to say symbol here) variable, or have the test 
in the same package (as opposed to a _test pkg)

I've gone with the latter, put these tests into the same package, thanks.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d6a6e01c-00df-47f7-94ac-a37e00cb73d7%40googlegroups.com.


[go-nuts] Unit testing AMQP/build flags for tests

2019-11-18 Thread Shane H
I'm trying to unit test some code (pasted below). I've struggled to find a 
way to mock the amqp.Connection, so have decided to go the monkey patching 
route.

The test 'works' but only if I use the following incantation 
go test -gcflags=-l

So, my next step is to ensure that -gcflags is set to prevent inlining when 
this test is executed. 
My /thought/ was to check os.Getenv("GO_GCFLAGS"), but as I was kindly 
reminded, executng the tests and compiling the tests are two different 
things.
My next brilliant idea was to use a build tag to ensure that the test file 
is only built when the flags are set as I desire. 
But https://golang.org/pkg/go/build/ doesn't offer any ideas where gcflags 
might be checked, or what tag to use.

So, I throw myself at the mercy of golang-nuts to (gently) point me in the 
right direction (I completely understand that there may be an easier way to 
do this, but I cannot see that path)

```
### Code to test
// MQ -
type MQ struct {
conn  *amqp.Connection
Retry int
URI   string
}

// Connect -
func (mq *MQ) Connect() (err error) {
// Retry MUST be > 0
if mq.Retry == 0 {
log.Print("Cannot use a Retry of zero, this process will to default retry 
to 1")
mq.Retry = 1
}

// Note: Even though amqp.ParseURI(uri) will validate the URI formed, check 
here that the minimum required exists
if mq.URI == "" {
log.Printf("No Message Queue URI configured")
}

for {
for i := 0; i < mq.Retry; i++ {
mq.conn, err = amqp.Dial(mq.URI)
if err == nil {
// Successful connection
log.Printf("Successfully connected to RabbitMQ")
return nil
}
time.Sleep(1 * time.Second)
}
// Log that there is a problem connecting to the RabbitMQ service that 
needs urgent attention
backoff := time.Duration(mq.Retry*rand.Intn(10)) * time.Second
log.Printf("ALERT: Trouble connecting to RabbitMQ, error: %v, going to 
re-enter retry loop in %s seconds", err, backoff.String())
time.Sleep(backoff)
}
}

### Test Code
func TestConnect(t *testing.T) {
testcases := map[string]struct {
retry int
uri   string
err   error
}{
"Happy Path": {retry: 1, uri: "amqp://localhost:5672/%2f"},
}
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
// Monkeypatch amqp to return the nil and the error
fakeRabbitConnection := func(msg string) (*amqp.Connection, error) {
return nil, tc.err // I only want the error to have meaning, therefore the 
connection can be nil (which also saves me having to create a mock)
}
patch := monkey.Patch(amqp.Dial, fakeRabbitConnection)
defer patch.Unpatch()
mq := rabbit.MQ{Retry: tc.retry, URI: tc.uri}
output := mq.Connect()
fmt.Println(output) // TODO
})
}
}
```

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/133174cd-e5ef-4e65-bfe0-e626914803bb%40googlegroups.com.


[go-nuts] unable to use golangci-lint against go-1.12.10 src

2019-09-27 Thread Shane H
On a whim I thought I'd see how the linters felt about the go src code, the 
current results for go 1.12.10 are below.

In the result you will note that I am unable to compile go because a file 
is missing (libtestgo2c2go.h). I cannot find it on my system, nor can I 
find it on the internet. 
The issue does not exist in go1.13.1, however I am not able to run the 
linters there either, because I get "ERRO Running error: context loading 
failed: failed to load program with go/packages: go [list -e -json 
-compiled=true -test=true -export=false -deps=true -find=false -- 
./src/...]: exit status 1: go build go/src/runtime/cgo: package using cgo 
has Go assembly file asm_amd64.s"

Any help on either or both issues appreciated (even if it's just a link to 
"This is how you do what you're trying to do")

$ golangci-lint run -v ./...
INFO [config_reader] Config search paths: [./ /home/shane/GoLang/src/go 
/home/shane/GoLang/src /home/shane/GoLang /home/shane /home /]
INFO [config_reader] Used config file ../../../.golangci.yml
INFO [lintersdb] Active 11 linters: [deadcode errcheck golint gosimple 
govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into 
metalinter megacheck
INFO [loader] Go packages loading at mode load types and syntax took 
1.131863478s
ERRO Running error: context loading failed: failed to load program with 
go/packages: go [list -e -json -compiled=true -test=true -export=false 
-deps=true -find=false -- ./...]: exit status 2: # go/misc/cgo/errors/src
misc/cgo/errors/src/issue28721.go:17:8: identifier "_Ctype_struct_a" may 
conflict with identifiers generated by cgo
misc/cgo/errors/src/issue28721.go:19:7: identifier "_Ctype_struct_a" may 
conflict with identifiers generated by cgo
misc/cgo/errors/src/issue28721.go:22:5: identifier "_Ctype_struct_a" may 
conflict with identifiers generated by cgo
misc/cgo/errors/src/issue28721.go:25:14: identifier "_Ctype_NotExist" may 
conflict with identifiers generated by cgo
misc/cgo/errors/src/issue28721.go:28:2: identifier "_Cfunc_fn" may conflict 
with identifiers generated by cgo
cgo:
gcc errors for preamble:
misc/cgo/errors/src/err1.go: In function 'test':
misc/cgo/errors/src/err1.go:11:2: error: 'xxx' undeclared (first use in 
this function)
  xxx;  // ERROR HERE
  ^~~
misc/cgo/errors/src/err1.go:11:2: note: each undeclared identifier is 
reported only once for each function it appears in

# go/misc/cgo/testcshared/src/go2c2go/m2
misc/cgo/testcshared/src/go2c2go/m2/main.go:7:11: fatal error: 
libtestgo2c2go.h: No such file or directory
 // #include "libtestgo2c2go.h"
   ^~
compilation terminated.
# go/misc/cgo/testsanitizers/src
gcc: error: unrecognized argument to -fsanitize= option: 'memory'
gcc: error: unrecognized argument to -fsanitize= option: 'memory'
# go/doc/progs
cgo: inconsistent package names: rand, rand2
# go/misc/cgo/testcshared/src/go2c2go/m1
c.c:5:10: fatal error: libtestgo2c2go.h: No such file or directory
 #include "libtestgo2c2go.h"
  ^~
compilation terminated.
# go/misc/cgo/testsovar
/usr/bin/ld: cannot find -lcgosotest
collect2: error: ld returned 1 exit status
# go/misc/cgo/testso
/usr/bin/ld: cannot find -lcgosotest
collect2: error: ld returned 1 exit status
go build go/src/runtime/cgo: package using cgo has Go assembly file 
asm_amd64.s

INFO Memory: 13 samples, avg is 68.9MB, max is 68.9MB
INFO Execution took 1.168364346s

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5d8341ca-1f24-409c-89cc-ab2c4dcbc8a6%40googlegroups.com.


Re: [go-nuts] Upgrade to Go1.12.7 problem

2019-08-06 Thread Shane H

>
>
> This looks like you unpacked a Go distribution into a directory that 
> already held another Go distribution.  Always unpack a Go distribution 
> into an empty directory. 
>
> Ian 
>

You could well be right, I think (from my perspective) the bigger issue is 
managing a Go installation on Ubuntu. 

The binary was updated correctly but, for whatever reason, the 
distribution? wasn't touched, not by the install, not by the purge. 

It was only that I found a helpful page dealing with a similar complaint, 
by googling the later error "does not match go tool version", that I 
discovered that the distribution was out of sync with the binary.

It can't be affecting too many other people, else I would have found more 
pages of people looking for help with the first error, before posting here.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c37dd524-dfe6-4962-90e6-49dadd31445e%40googlegroups.com.


[go-nuts] Re: Upgrade to Go1.12.7 problem [SOLVED]

2019-08-05 Thread Shane H


On Tuesday, August 6, 2019 at 11:31:40 AM UTC+10, Shane H wrote:
>
>
>
> On Tuesday, August 6, 2019 at 10:56:42 AM UTC+10, Shane H wrote:
>>
>> Hi all,
>>
>> I've done a bit of searching, and asked around, but not found an answer 
>> to my (most likely self-inflicted) problem.
>>
>> I have been coding with Go 1.10 and 1.11 for a whiles, but I decided that 
>> it was time to join the future and upgraded to 1.12. It worked fine for the 
>> project I was creating at the time, but after some time (long enough for me 
>> to forget the steps I took to upgrade!) I discovered issues with my install.
>>
>> I've tried to reinstall (Ubuntu, apt purge golang-1.* ) and reinstall, to 
>> no avail.
>>
>> I need to know what I can check to stop this behaviour, sans reinstalling 
>> the OS
>>
>> This is probably best demonstrated as:
>> shane@desktop ~/GoLang/src/github.com/ipfs/go-ipfs (master) $ make build
>> go version go1.12.7 linux/amd64
>> bin/check_go_version 1.12
>> go build  "-asmflags=all='-trimpath=/home/shane/GoLang'" 
>> "-gcflags=all='-trimpath=/home/shane/GoLang'" -ldflags="-X "
>> github.com/ipfs/go-ipfs".CurrentCommit=641d9f6b0-dirty" -o 
>> "cmd/ipfs/ipfs" "github.com/ipfs/go-ipfs/cmd/ipfs"
>> /usr/local/go/src/crypto/tls/cipher_suites.go:18:2: unknown import path 
>> "golang_org/x/crypto/chacha20poly1305": cannot find module providing 
>> package golang_org/x/crypto/chacha20poly1305
>> /usr/local/go/src/crypto/x509/x509.go:36:2: unknown import path 
>> "golang_org/x/crypto/cryptobyte": cannot find module providing package 
>> golang_org/x/crypto/cryptobyte
>> /usr/local/go/src/crypto/x509/x509.go:37:2: unknown import path 
>> "golang_org/x/crypto/cryptobyte/asn1": cannot find module providing package 
>> golang_org/x/crypto/cryptobyte/asn1
>> /usr/local/go/src/crypto/tls/key_agreement.go:18:2: unknown import path 
>> "golang_org/x/crypto/curve25519": cannot find module providing package 
>> golang_org/x/crypto/curve25519
>> /usr/local/go/src/net/dnsclient.go:11:2: unknown import path 
>> "golang_org/x/net/dns/dnsmessage": cannot find module providing package 
>> golang_org/x/net/dns/dnsmessage
>> /usr/local/go/src/net/http/h2_bundle.go:47:2: unknown import path 
>> "golang_org/x/net/http/httpguts": cannot find module providing package 
>> golang_org/x/net/http/httpguts
>> /usr/local/go/src/net/http/transport.go:34:2: unknown import path 
>> "golang_org/x/net/http/httpproxy": cannot find module providing package 
>> golang_org/x/net/http/httpproxy
>> /usr/local/go/src/net/http/h2_bundle.go:48:2: unknown import path 
>> "golang_org/x/net/http2/hpack": cannot find module providing package 
>> golang_org/x/net/http2/hpack
>> /usr/local/go/src/net/http/h2_bundle.go:49:2: unknown import path 
>> "golang_org/x/net/idna": cannot find module providing package 
>> golang_org/x/net/idna
>> cmd/ipfs/Rules.mk:22: recipe for target 'cmd/ipfs/ipfs' failed
>> make: *** [cmd/ipfs/ipfs] Error 1
>>
>>
>> $ go env
>> GOARCH="amd64"
>> GOBIN=""
>> GOCACHE="/home/shane/.cache/go-build"
>> GOEXE=""
>> GOFLAGS=""
>> GOHOSTARCH="amd64"
>> GOHOSTOS="linux"
>> GOOS="linux"
>> GOPATH="/home/shane/GoLang"
>> GOPROXY=""
>> GORACE=""
>> GOROOT="/usr/local/go"
>> GOTMPDIR=""
>> GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
>> GCCGO="gccgo"
>> CC="gcc"
>> CXX="g++"
>> CGO_ENABLED="1"
>> GOMOD=""
>> CGO_CFLAGS="-g -O2"
>> CGO_CPPFLAGS=""
>> CGO_CXXFLAGS="-g -O2"
>> CGO_FFLAGS="-g -O2"
>> CGO_LDFLAGS="-g -O2"
>> PKG_CONFIG="pkg-config"
>> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=/tmp/go-build529069743=/tmp/go-build 
>> -gno-record-gcc-switches"
>>  
>>
>
>> The issue is now showing up in my vim, golangci-lint is complaining of 
>> errors
>> /usr/local/go/src/net/dnsclient.go|11 col 2| could not import 
>> golang_org/x/net/dns/dnsmessage (invalid package name: "")
>>
>
> When I try to upgrade my gopls server I get
> $ env GO111MODULE=on go get golang.org/x/tools/gopls@latest
> go: finding golang.org/x/tools/gopls v0.1.3
>

[go-nuts] Re: Upgrade to Go1.12.7 problem

2019-08-05 Thread Shane H


On Tuesday, August 6, 2019 at 10:56:42 AM UTC+10, Shane H wrote:
>
> Hi all,
>
> I've done a bit of searching, and asked around, but not found an answer to 
> my (most likely self-inflicted) problem.
>
> I have been coding with Go 1.10 and 1.11 for a whiles, but I decided that 
> it was time to join the future and upgraded to 1.12. It worked fine for the 
> project I was creating at the time, but after some time (long enough for me 
> to forget the steps I took to upgrade!) I discovered issues with my install.
>
> I've tried to reinstall (Ubuntu, apt purge golang-1.* ) and reinstall, to 
> no avail.
>
> I need to know what I can check to stop this behaviour, sans reinstalling 
> the OS
>
> This is probably best demonstrated as:
> shane@desktop ~/GoLang/src/github.com/ipfs/go-ipfs (master) $ make build
> go version go1.12.7 linux/amd64
> bin/check_go_version 1.12
> go build  "-asmflags=all='-trimpath=/home/shane/GoLang'" 
> "-gcflags=all='-trimpath=/home/shane/GoLang'" -ldflags="-X "
> github.com/ipfs/go-ipfs".CurrentCommit=641d9f6b0-dirty" -o 
> "cmd/ipfs/ipfs" "github.com/ipfs/go-ipfs/cmd/ipfs"
> /usr/local/go/src/crypto/tls/cipher_suites.go:18:2: unknown import path 
> "golang_org/x/crypto/chacha20poly1305": cannot find module providing 
> package golang_org/x/crypto/chacha20poly1305
> /usr/local/go/src/crypto/x509/x509.go:36:2: unknown import path 
> "golang_org/x/crypto/cryptobyte": cannot find module providing package 
> golang_org/x/crypto/cryptobyte
> /usr/local/go/src/crypto/x509/x509.go:37:2: unknown import path 
> "golang_org/x/crypto/cryptobyte/asn1": cannot find module providing package 
> golang_org/x/crypto/cryptobyte/asn1
> /usr/local/go/src/crypto/tls/key_agreement.go:18:2: unknown import path 
> "golang_org/x/crypto/curve25519": cannot find module providing package 
> golang_org/x/crypto/curve25519
> /usr/local/go/src/net/dnsclient.go:11:2: unknown import path 
> "golang_org/x/net/dns/dnsmessage": cannot find module providing package 
> golang_org/x/net/dns/dnsmessage
> /usr/local/go/src/net/http/h2_bundle.go:47:2: unknown import path 
> "golang_org/x/net/http/httpguts": cannot find module providing package 
> golang_org/x/net/http/httpguts
> /usr/local/go/src/net/http/transport.go:34:2: unknown import path 
> "golang_org/x/net/http/httpproxy": cannot find module providing package 
> golang_org/x/net/http/httpproxy
> /usr/local/go/src/net/http/h2_bundle.go:48:2: unknown import path 
> "golang_org/x/net/http2/hpack": cannot find module providing package 
> golang_org/x/net/http2/hpack
> /usr/local/go/src/net/http/h2_bundle.go:49:2: unknown import path 
> "golang_org/x/net/idna": cannot find module providing package 
> golang_org/x/net/idna
> cmd/ipfs/Rules.mk:22: recipe for target 'cmd/ipfs/ipfs' failed
> make: *** [cmd/ipfs/ipfs] Error 1
>
>
> $ go env
> GOARCH="amd64"
> GOBIN=""
> GOCACHE="/home/shane/.cache/go-build"
> GOEXE=""
> GOFLAGS=""
> GOHOSTARCH="amd64"
> GOHOSTOS="linux"
> GOOS="linux"
> GOPATH="/home/shane/GoLang"
> GOPROXY=""
> GORACE=""
> GOROOT="/usr/local/go"
> GOTMPDIR=""
> GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
> GCCGO="gccgo"
> CC="gcc"
> CXX="g++"
> CGO_ENABLED="1"
> GOMOD=""
> CGO_CFLAGS="-g -O2"
> CGO_CPPFLAGS=""
> CGO_CXXFLAGS="-g -O2"
> CGO_FFLAGS="-g -O2"
> CGO_LDFLAGS="-g -O2"
> PKG_CONFIG="pkg-config"
> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=/tmp/go-build529069743=/tmp/go-build 
> -gno-record-gcc-switches"
>  
>

> The issue is now showing up in my vim, golangci-lint is complaining of 
> errors
> /usr/local/go/src/net/dnsclient.go|11 col 2| could not import 
> golang_org/x/net/dns/dnsmessage (invalid package name: "")
>

When I try to upgrade my gopls server I get
$ env GO111MODULE=on go get golang.org/x/tools/gopls@latest
go: finding golang.org/x/tools/gopls v0.1.3
go: finding golang.org/x/tools v0.0.0-20190710153321-831012c29e42
go: finding golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/text v0.3.0
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: downloading golang.org/x/tools v0.0.0-20190710153321-831012c29e42
go: extracting golang.org/x/tools v0.0.0-20190

[go-nuts] Upgrade to Go1.12.7 problem

2019-08-05 Thread Shane H
Hi all,

I've done a bit of searching, and asked around, but not found an answer to 
my (most likely self-inflicted) problem.

I have been coding with Go 1.10 and 1.11 for a whiles, but I decided that 
it was time to join the future and upgraded to 1.12. It worked fine for the 
project I was creating at the time, but after some time (long enough for me 
to forget the steps I took to upgrade!) I discovered issues with my install.

I've tried to reinstall (Ubuntu, apt purge golang-1.* ) and reinstall, to 
no avail.

I need to know what I can check to stop this behaviour, sans reinstalling 
the OS

This is probably best demonstrated as:
shane@desktop ~/GoLang/src/github.com/ipfs/go-ipfs (master) $ make build
go version go1.12.7 linux/amd64
bin/check_go_version 1.12
go build  "-asmflags=all='-trimpath=/home/shane/GoLang'" 
"-gcflags=all='-trimpath=/home/shane/GoLang'" -ldflags="-X 
"github.com/ipfs/go-ipfs".CurrentCommit=641d9f6b0-dirty" -o "cmd/ipfs/ipfs" 
"github.com/ipfs/go-ipfs/cmd/ipfs"
/usr/local/go/src/crypto/tls/cipher_suites.go:18:2: unknown import path 
"golang_org/x/crypto/chacha20poly1305": cannot find module providing 
package golang_org/x/crypto/chacha20poly1305
/usr/local/go/src/crypto/x509/x509.go:36:2: unknown import path 
"golang_org/x/crypto/cryptobyte": cannot find module providing package 
golang_org/x/crypto/cryptobyte
/usr/local/go/src/crypto/x509/x509.go:37:2: unknown import path 
"golang_org/x/crypto/cryptobyte/asn1": cannot find module providing package 
golang_org/x/crypto/cryptobyte/asn1
/usr/local/go/src/crypto/tls/key_agreement.go:18:2: unknown import path 
"golang_org/x/crypto/curve25519": cannot find module providing package 
golang_org/x/crypto/curve25519
/usr/local/go/src/net/dnsclient.go:11:2: unknown import path 
"golang_org/x/net/dns/dnsmessage": cannot find module providing package 
golang_org/x/net/dns/dnsmessage
/usr/local/go/src/net/http/h2_bundle.go:47:2: unknown import path 
"golang_org/x/net/http/httpguts": cannot find module providing package 
golang_org/x/net/http/httpguts
/usr/local/go/src/net/http/transport.go:34:2: unknown import path 
"golang_org/x/net/http/httpproxy": cannot find module providing package 
golang_org/x/net/http/httpproxy
/usr/local/go/src/net/http/h2_bundle.go:48:2: unknown import path 
"golang_org/x/net/http2/hpack": cannot find module providing package 
golang_org/x/net/http2/hpack
/usr/local/go/src/net/http/h2_bundle.go:49:2: unknown import path 
"golang_org/x/net/idna": cannot find module providing package 
golang_org/x/net/idna
cmd/ipfs/Rules.mk:22: recipe for target 'cmd/ipfs/ipfs' failed
make: *** [cmd/ipfs/ipfs] Error 1


$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/shane/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/shane/GoLang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=/tmp/go-build529069743=/tmp/go-build 
-gno-record-gcc-switches"


The issue is now showing up in my vim, golangci-lint is complaining of 
errors
/usr/local/go/src/net/dnsclient.go|11 col 2| could not import 
golang_org/x/net/dns/dnsmessage (invalid package name: "")

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1578e939-7aa9-4bb6-ba09-f0405f98b5ce%40googlegroups.com.


Re: [go-nuts] To make AI with Golang

2018-08-17 Thread Shane
On Sat, Aug 18, 2018 at 2:56 PM John  wrote:
>
> Hi I am trying to make an game of Connect Five using Golang, I have 
> already made an player versus player mode so I am making the player versus 
> computer mode.

I think what you are looking for is adversarial graph search, min/max
with alpha/beta pruning

It's not (strictly speaking) Go specific, and a basic explanation can
be found at https://www.cs.cornell.edu/courses/cs312/2002sp/lectures/rec21.htm

You'll need to create a graph in memory with each node being a state
of the board, and each edge being a legal move out of the node into
another state. You'll also need to decide what constitutes a good move
(so you can award a 'strength' to each state, in one players favour or
the others) and finally you'll need to determine how many moves into
the future your application will search for it's optimal move. The
better your strength statistic is at determining optimal board states,
and the further into the future your graph will look, the better your
'AI' will be. But be aware that the limitations of time and memory
will constrain how far into the future you can look.

> At first I attempted to use if functions that detect when they need to block 
> the player but it can't win without placing blocks for itself. Also another 
> problem is that the computer have a chance on placing on the player's block. 
> So I need some help, I know you are all wonderful coders.
>
> --
> 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] Examples testing with two newline, but only one newline

2018-08-13 Thread Shane
Hmm I meant to reply to the group but I think I inadvertantly replied
directly (my apologies).

I'll repost my answer because I think that it may help others with the same
issue (the multi line examples!)

Hi

There are two ways to use examples with multi line outputs

1) Multi line comments (Be aware that whitespace may become an issue)

/* Output: Line1
Line 2
*/


2) Multiple single line comments (my preference)

// Output: Line1
// Line 2

HTH

On Sat, Aug 11, 2018 at 6:09 PM,  wrote:

> Hi
>
> https://play.golang.org/p/AIB-yJaExVu
>
> When I want to use examples to test my code, I find something odd.
> Example1 could pass, but Example2 failed
>
> --- FAIL: Example2 (0.00s)
>> got:
>> hello
>> .
>>
>> 123
>> want:
>> hello
>> .
>> 123
>> FAIL
>> exit status 1
>
>
> It seems Examples could only show one newline.
> Is there a solution to solve it? Thanks
>
> --
> 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.