Re: [go-nuts] [ANN] Frame - Plan9 libframe in Go

2017-10-11 Thread roger peppe
Cool! Out of interest, does it cope with characters whose bounding
boxes overlap (e.g. ff)? That's a particular failing of the original
frame library, which assumes every character lives alone in its own
distinct box.

On 11 October 2017 at 04:30, as  wrote:
> For those of you who miss the Plan9 editable text boxes, here's a Go package
> that approximates them:
>
> https://github.com/as/frame
>
> It's not a c2go conversion, but the functionality is almost identical at the
> API level.
>
> A few extra things added
>
> - Raw ASCII bytes
> - Elastic tabstops
> - Semantic Replacement Characters
>
> --
> 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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Pat Farrell
On Wed, Oct 11, 2017 at 11:32 PM,  wrote:

> Did you install the Windows or Linux go binary distribution?
>

I went to the distribution site and installed the .msi file
like any windows installation

I've been running bash since about 1987, so I'm partial to it.

Other than the file names, I'm not convinced that there is any actual
difference
between the go.exe you get with the MSI and the go binary that apt-get
installs

I've got it running now, but I am not sure exactly what I did to get it all
working (altho the symlink was obvious)

Bill, between you and I, we have 70+ years experience at this, you'd think
we could get a compiler installed.

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread bnixon67
Did you install the Windows or Linux go binary distribution?

Sounds like you might have installed the Window distribution and running it 
in bash?

I installed the Linux go distribution and it worked just fine. I think I 
created a symlink from /usr/local/go/bin/go to /usr/local/bin/go, or you 
can alter your $PATH to include /usr/local/go/bin so you get access to go, 
good, and gofmt.

On Wednesday, October 11, 2017 at 12:04:28 AM UTC-5, Pat Farrell wrote:
>
> I've installed the go 1.9 binary distribution on my windows 10 laptop. 
> I just let the install do the defaults. (in addition to learning go, I'm 
> trying to see if I can live with 
> bash under Windows, or if I have to reboot to a linux distro to avoid 
> going crazy, that is a separate topic)
>
> in the cmd shell
> 'go build' works, but creates a file go.exe that when run, displays hello 
> world
> it does not create the expected hello.exe
>
> in the bash shell, 'go build' does not work, it whines that 'go' is not a 
> program
>
> The program 'go' is currently not installed. You can install it by typing:
> sudo apt-get install gccgo-go
>
>
>
> but 'go.exe build' does create a local go.exe which executes and displays 
> the expected hello world.
>
> Which raises a couple of questions:
>
> 1) is the standard documentation wrong/out of date?
> 2) how do I get the go build process to create a hello.exe rather than 
> go.exe?
> 3) how do I get the bash shell to let me just type 'go build' like we all 
> want?
>
>
>
>

-- 
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: Building a neural net from scratch

2017-10-11 Thread Alex Buchanan
I just happen to have read your "Common Go for Data Science Questions" post 
this morning and loved it. Looking forward to reading the rest of your 
stuff. Keep up the great work.

I'm writing Go for infrastructure in an environment (computational biology) 
surrounded by data scientists writing python and R, so I've been wondering 
if Go could help them.

Cheers,
A

On Wednesday, October 11, 2017 at 1:10:36 PM UTC-7, Daniel Whitenack wrote:
>
> Hi all. I just released a blog post about building a neural net in Go from 
> scratch: http://www.datadan.io/building-a-neural-net-from-scratch-in-go/. 
> Hope this is interesting for some and inspires more of this sort of thing. 
> Would love to talk about it here or in the #data-science channel on Slack. 
>
> Best,
> Daniel
>

-- 
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] [ANN] Frame - Plan9 libframe in Go

2017-10-11 Thread Nigel Tao
On Wed, Oct 11, 2017 at 2:30 PM, as  wrote:
> https://github.com/as/frame

Nice!

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread brainman
On Thursday, 12 October 2017 11:23:08 UTC+11, Pat Farrell wrote:
> ... But there was nothing that told me why.

Are you asking me why all your Go code should live inside of single 
directory? Hopefully others will reply. But I think it is because Go does 
not use any config files to build programs. There are no "project files" or 
"Makefile" or whatever. Go tools use your directory structure to work out 
how to build things.

> Again, it looks like someone who hated Windows (and I hate Windows as 
much as any other developer) was forced to implement it and wrote the 
minimal documentation they could. They did this long ago, and no one has 
updated it

That is what we have. If you think you can make it better, feel free to 
contribute or at least report an issue at https://golang.org/issue

> Seriously? That sure seem like bad practices to me. Nearly all the code 
I've worked on over the past 40 years was too big to go into a single 
directory.

Well Go tools put everything under GOPATH.

> Which is a Linux-type instruction. Doesn't work on Windows

`set GOPATH=c:\gopath` works for me on Windows. On Linux you want something 
like `export GOPATH=/home/alex/gopath` (this depends on what shell you use).

>> Sure. But Go is still not supported on WSL.
> 
> That is a bug.

Yes, it is a bug. I hope Microsoft are working on fixing these.
 
>> If you want to use development environment with bugs, then sure, you 
could do that. 
>
> I'm sorry, this attitude is not helpful.

I did not intend to offend you, I apologize if I did. I just stated the 
fact that WSL is too buggy to be used for development (in my opinion). But 
you are free to use whatever tools you like.

> The installation for binaries uses some standard Windows installation 
tool, been the same since about Windows 95. Its clearly not written in go

Or yes. Go installation program (like many others on Windows) is built 
using "WiX Toolset". But you don't even have to use that. You can just 
download Go as a zip file (search for "Zip archive" on 
https://golang.org/doc/install )

> I have now been dorking around on this for a couple of days.

I think you are making things harder for yourself by trying to mix 2 new 
things at the same time: Go and WSL. I suggest you try and use Linux 
version of Go on your Linux computer or use Windows version of Go on your 
Windows computer. These scenarios are very common and people will quickly 
help you with that.

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.


[go-nuts] Why go does't have NullInt type on database/sql?

2017-10-11 Thread 高橋誠二
There are NullInt64 and NullFloat64, but not about NullInt, NullFloat. (or 
NullInt32 etc...)
After scanning from rds, my team always convert them to int, but it seems 
so silly.
What is the reason?

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Pat Farrell
I found how to force 'go build' to work under the bash shell on Winderz
you have to add a symlink in the program directory containing go.exe
such as 
ln -s go.exe go


On Wednesday, October 11, 2017 at 7:59:04 PM UTC-4, brainman wrote:
>
> On Thursday, 12 October 2017 09:28:42 UTC+11, Pat Farrell wrote:
> > Yes, I didn't understand what a "workspace" is. Still don't know what 
> that buzzword means.
>
> I suggested you read https://golang.org/doc/code.html - it should answer 
> your question. 
>

I saw you write that. But there was nothing that told me why.
I started at golang.org and have been following the instructions.
There was no reference to this document in any of the installation 
instruction pages.

Again, it looks like someone who hated Windows (and I hate Windows as much 
as any other developer) 
was forced to implement it and wrote the minimal documentation they could. 
They did this long ago, and no one has updated it



|| when you write programs with Go all your source code, compiled packages 
and final binaries will be stored inside of single 
|| directory on your computer. 

Seriously? That sure seem like bad practices to me. Nearly all the code 
I've worked on over the past 40 years was too big to go into a single 
directory.



```
> set GOPATH=c:\gopath
> ```
>

Which is a Linux-type instruction. Doesn't work on Windows


 
> > That thread is at least a year old. Back then it was in Beta from MS. 
> Its released now.
>
> Sure. But Go is still not supported on WSL.
>

That is a bug.

 

>  If you want to use development environment with bugs, then sure, you 
> could do that. 
>

I'm sorry, this attitude is not helpful.




> > Go is claimed to be cross platform, and the language sure looks to be 
> that way. But the installation instructions on Windows seem to be an 
> afterthought and fairly out of date.
>
> It is hard for me to judge (I have used Go for many years). 
>

Clearly you have not tried to start with zero knowledge on windows.
I'm sure its much easier if you use a prefered OS such as Linux.


> Go, its libraries and tools are written in Go. So Go installation does not 
> installs any gnu / cygwin stuff. 
>

The installation for binaries uses some standard Windows installation tool, 
been the same since about Windows 95.
Its clearly not written in go

Perhaps once I get this all working, I'll see the native go tools and 
libraries. But I'm not there yet.

I have now been dorking around on this for a couple of days. If I was not 
intrigued about how great go would be, I'd have stopped already. Something 
that I randomly clicked on to make this work started a cygwin shell. I have 
no idea what. Nor do I know what installed it.

I'd rather that this remain unanswered until someone who has active 
knowledge about what is happening with the go on Windows installation can 
chime in.

Thanks
Pat

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread brainman
On Thursday, 12 October 2017 09:28:42 UTC+11, Pat Farrell wrote:

> Yes, I didn't understand what a "workspace" is. Still don't know what 
that buzzword means.

I suggested you read https://golang.org/doc/code.html - it should answer 
your question. But if you prefer me explaining it (and I am not as good as 
people who wrote the doco), when you write programs with Go all your source 
code, compiled packages and final binaries will be stored inside of single 
directory on your computer. It is up to you to decide where that directory 
is, but all Go tools would expect to find that directory path in GOPATH 
environment variable. All your source files have to be stored under 
%GOPATH%\src, all compiled packages will go into %GOPATH%\pkg and all 
compiled binaries will be installed into %GOPATH%\bin. So, if you do
```
set GOPATH=c:\gopath
```
then create this file
```
c:\gopath\src\hello>type main.go
package main

import "fmt"

func main() {
fmt.Println("Helle")
}

c:\gopath\src\hello>
```
in c:\gopath\src\hello directory and then run "go install hello" command, 
it will create c:\gopath\bin\hello.exe with your program. "go install" and 
"go build" commands do not care about source file names, they care about 
package names, and package name is determined by the directory where your 
source files are stored. For example the same file could be copied into 
c:\gopath\src\a\b\c\alex directory, and then you would have to do "go 
install a/b/c/alex" to build and install it, and that would create 
c:\gopath\bin\alex.exe executable.

Hopefully this will get you started, but there is much more to Go tools. 
You should start learning by reading https://golang.org/doc/code.html

> So I created a directory in my sandbox called 'go' and got go.exe

Yes. "go build" command uses directory name to decide what the package name 
is, and therefore what the output binary will be called. You could use -o 
flag to override that, but you should try and live by Go conventions first, 
you might discover that these work for you.
 
> That thread is at least a year old. Back then it was in Beta from MS. Its 
released now.

Sure. But Go is still not supported on WSL. There were few issues reported 
about Go on WSL (you could search https://golang.org/issue ). Some of them 
are quite basic, like deleting all files in a directory does not delete all 
files. If you want to use development environment with bugs, then sure, you 
could do that. Just start here https://golang.org/doc/install but use Linux 
instructions, not Windows instructions.

> But I'm trying to learn go and while I have three or four Linux machines 
and an OS-X one, my day to day laptop is Windows because I need Lightroom, 
Photoshop and Premier, and I am tired of paying for Apple's over priced, 
under performing laptops.

Go works pretty much the same on any OS (bar file paths and couple of small 
things). Same commands, same tools. You can build any Go program on any OS 
for any OS (except when your program uses any libraries written in C). So 
whatever OS you prefer is fine. Some people use Plan 9 to develop in Go.

> Go is claimed to be cross platform, and the language sure looks to be 
that way. But the installation instructions on Windows seem to be an 
afterthought and fairly out of date.

It is hard for me to judge (I have used Go for many years). If you think 
you could improve the documentation, you are welcome to contribute 
https://golang.org/doc/contribute.html

> I'm surprised that the default Windows binary installation still installs 
the gnu / cygwin stuff which has never "supported" anything.

Go, its libraries and tools are written in Go. So Go installation does not 
installs any gnu / cygwin stuff. Give me an example, if you know otherwise.

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.


[go-nuts] Re: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Kevin Malachowski
Why do you need all of your factories to have a common parameter?

Also, what problem are you trying to solve? If you're just trying to organize 
your code, to what end are you pursuing this generalization? That is, what 
would you like your final code to look like? (Feel free to use psuedocode to 
get your point across.)

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Pat Farrell

On Wednesday, October 11, 2017 at 6:08:26 PM UTC-4, brainman wrote:
>
> > On Thursday, 12 October 2017 02:34:49 UTC+11, Pat Farrell wrote:
> > https://golang.org/doc/install
>
> This one says "... Next, make the directory src/hello inside your 
> workspace ...". And, I take it, you skipped that step.
>

Yes, I didn't understand what a "workspace" is. Still don't know what that 
buzzword means. So I created a directory in my sandbox called 'go'
and got go.exe


 

> > ... Microsoft has decided to provide a real bash shell with real Ubuntu 
> utilities. It has apt-get and is pretty nice, way better than the old cmd 
> shell
> https://msdn.microsoft.com/en-us/commandline/wsl/about
>
> If you want to use WSL, then you should treat it as Linux (because it is 
> not Windows). So you should install Linux version of Go on WSL, not Windows 
> version. And WSL is not supported by Go yet (see 
> https://github.com/golang/go/issues/16628 for details).
>


That thread is at least a year old. Back then it was in Beta from MS. Its 
released now.

I know, almost all developers use either OS-X or a Linux for development. I 
did too when I did it full time.
But I'm trying to learn go and while I have three or four Linux machines 
and an OS-X one, my day to day
laptop is Windows because I need Lightroom, Photoshop and Premier, and I am 
tired of paying for Apple's over priced, under
performing laptops.

Go is claimed to be cross platform, and the language sure looks to be that 
way. But the installation instructions
on Windows seem to be an afterthought and fairly out of date. I wish the 
world's desktops were not Windows, but 
I'm not in charge of that.

I'm surprised that the default Windows binary installation still installs 
the gnu / cygwin stuff
which has never "supported" anything.

 

> I hope it helps.
>

The information does. Thanks
 
If there needs to be tips or hints about which go setup to use on Windows, 
that sounds good to me.
Maybe even a discussion of why you would want to use one approach (with 
cygwin) against another (using WSL)

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread brainman
> On Thursday, 12 October 2017 02:34:49 UTC+11, Pat Farrell wrote:
> 
> https://golang.org/doc/install

This one says "... Next, make the directory src/hello inside your workspace 
...". And, I take it, you skipped that step.

> ... Microsoft has decided to provide a real bash shell with real Ubuntu 
utilities. It has apt-get and is pretty nice, way better than the old cmd 
shell
https://msdn.microsoft.com/en-us/commandline/wsl/about

If you want to use WSL, then you should treat it as Linux (because it is 
not Windows). So you should install Linux version of Go on WSL, not Windows 
version. And WSL is not supported by Go yet (see 
https://github.com/golang/go/issues/16628 for details).

I hope it helps.

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.


[go-nuts] Re: DNS Resolver options

2017-10-11 Thread 'Pushkar' via golang-nuts
Thanks Dave. I am aware of that repo but it doesn't provide an abstraction 
of the resolver functionality.
I found https://github.com/bogdanovich/dns_resolver which is written using 
miekg/dns. It is lacking some of the options that libraries like c-ares 
have (using TCP and controlling timeout).
I think I can extend it by figuring out how to force a TCP query and 
timeout the query, but wanted to check with the group if I am overlooking 
something.

On Wednesday, October 11, 2017 at 1:58:47 PM UTC-7, Dave Cheney wrote:
>
> Try https://github.com/miekg/dns

-- 
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] DNS Resolver options

2017-10-11 Thread Dave Cheney
Try https://github.com/miekg/dns

-- 
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] DNS Resolver options

2017-10-11 Thread 'Pushkar' via golang-nuts
Hello,
I would like to control the dns lookup timeout, the number of retries and 
also the ability to use TCP for the DNS resolution.
I am from the C/C++ world and c-ares has options to control these.
I am not findiing either of these as options in the go net package.
Am I not looking in the right place or is there a package that I should use.
Thanks,
pushkar

-- 
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: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Frank Ruiz
Thank you Alex for the link. Will check it out.

To further clarify, the issue I am having is with:

opts …func(*procStruct)
opts …func(*sysStruct)

I have multiple structs other than *procStruct (as listed in the example), 
so I am trying to find the best way to generalize this parameter so I can 
have a common parameter for my factories. 

Here is a reference link for the pattern I am using for inspiration:

http://matthewbrown.io/2016/01/23/factory-pattern-in-golang/

As you can see in the above link, the factories use a common parameter.. 
however, I am trying to adapt this for functional options.

Thank you for the reply!



On Wednesday, October 11, 2017 at 12:22:55 PM UTC-7, Alex Buchanan wrote:
>
> I'm not sure I understand the example, but have you seen the grpc 
> library's use of options? For more type safety, you could define an 
> interface such as type PluginOpt interface { pluginOpt() }.
>
> https://godoc.org/google.golang.org/grpc#CallOption
>
> On Wednesday, October 11, 2017 at 11:23:16 AM UTC-7, Frank Ruiz wrote:
>>
>> Greetings,
>>
>> Was hoping to solicit some feedback on utilizing functional options in 
>> conjunction with factory methods.
>>
>> I currently have the following function:
>>
>> func ProcPlugin(opts …func(*procStruct){
>> p := defaulProc
>> for _, opt := range opts {
>> opt(&p)
>> }
>> return &p, nil
>> }
>>
>> I am now trying to generalize things (as I will be creating more factory 
>> functions), and I'm trying to determine if this is the most optimal way to 
>> represent the logic above.
>>
>> type PluginFactory func(opts ...interface{}) (Plugin, error)
>>
>> func NewProcPlugin(opts ...interface{}) (Plugin, error) {
>> p := defaulProc
>> for _, opt := range opts {
>> opt(&p)
>> }
>> return &p, nil
>> }
>>
>> Any feedback would be much appreciated. Please let me know if more 
>> context is required.
>>
>> Thank you!
>>
>

-- 
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] Gomobile and SAF

2017-10-11 Thread audrius . butkevicius
So I've been going back and forth with this 
in https://github.com/golang/go/issues/105808.

Syncthing on Android consists of two parts, one is the actual android 
UI/wrapper, and second is GOOS=linux GOARCH=arm Go binary that the android 
UI starts and manipulates using a rest API.

>From the Go binary, we need to call into Java and get a file descriptor to 
file on the SD card with write permissions.
Normal os.Open doesn't cut it, as permissions on the sdcard are managed via 
Storage Access Framework, so we have to go through that in Java call a few 
other functions to get a writable fd.

In Go terms I expect to do something like this

import (
   "Java/android/content/ContentProvider"   
   "Java/android/content/Intent"

)

func Open(name string) (*os.File, error) {
//Java/Go pseudo code
try {
var contentProvider = ContentProvider 

();
// Get write permissions
contentProvider.getContext().getContentResolver().
takePersistableUriPermission(name, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | 
Intent.FLAG_GRANT_READ_URI_PERMISSION);
// At this point it probably doesn't matter if we get the FD using 
Java or Go...
var fdFromJava = contentProvider.openFile(name).getFd();
return os.NewFile(fdFromJava, name), nil
} catch {
return nil, errors.New("welp")
}
}



Elias on the ticket suggests that forward gomobile bind should be enough, 
yet I can't comprehend on how this is the case and how this would work, as 
all examples of forward bindings I find show calling Go from Java not the 
other way around.
As in, the call is initiated from Java side, which should not be the case 
in this case, as we are running in a Go binary.

Can someone provide more clarity on how this can be achieved?

Even if we do reverse bindings, can we actually make all the calls we want 
without having an activity in the current process/JVM?





Unrelated, but I thought I'll give gomobile bind a test to see what I end 
up with and I get the following:

c:\gopath\src\github.com\syncthing\syncthing\lib\fs>gomobile bind
gomobile: go build -pkgdir=c:\gopath\pkg\gomobile/pkg_android_arm -buildmode
=c-shared -o=C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\
android\src\main\jniLibs\armeabi-v7a\libgojni.so C:\Users\Audrius\AppData\
Local\Temp\gomobile-work-804905487\androidlib\main.go failed: exit status 2
# 
_/C_/Users/Audrius/AppData/Local/Temp/gomobile-work-804905487/gomobile_bind
C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\gomobile_bind\
go_fsmain.go:243: cannot use (*proxyfs_Filesystem)(_v_ref) (type *
proxyfs_Filesystem) as type fs.Filesystem in assignment:
*proxyfs_Filesystem does not implement fs.Filesystem (missing Chmod 
method)
C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\gomobile_bind\
go_fsmain.go:722: cannot use (*proxyfs_FileInfo)(res_0_ref) (type *
proxyfs_FileInfo) as type fs.FileInfo in assignment:
*proxyfs_FileInfo does not implement fs.FileInfo (missing ModTime 
method)
C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\gomobile_bind\
go_fsmain.go:1170: cannot use (*proxyfs_FileInfo)(res_0_ref) (type *
proxyfs_FileInfo) as type fs.FileInfo in assignment:
*proxyfs_FileInfo does not implement fs.FileInfo (missing ModTime 
method)
C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\gomobile_bind\
go_fsmain.go:1284: cannot use (*proxyfs_FileInfo)(res_0_ref) (type *
proxyfs_FileInfo) as type fs.FileInfo in assignment:
*proxyfs_FileInfo does not implement fs.FileInfo (missing ModTime 
method)
C:\Users\Audrius\AppData\Local\Temp\gomobile-work-804905487\gomobile_bind\
go_fsmain.go:1465: cannot use (*proxyfs_Filesystem)(_param_next_ref) (type *
proxyfs_Filesystem) as type fs.Filesystem in assignment:
*proxyfs_Filesystem does not implement fs.Filesystem (missing Chmod 
method)


-- 
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] Building a neural net from scratch

2017-10-11 Thread Daniel Whitenack
Hi all. I just released a blog post about building a neural net in Go from 
scratch: http://www.datadan.io/building-a-neural-net-from-scratch-in-go/. 
Hope this is interesting for some and inspires more of this sort of thing. 
Would love to talk about it here or in the #data-science channel on Slack. 

Best,
Daniel

-- 
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] Sync pool old data

2017-10-11 Thread Ian Lance Taylor
On Wed, Oct 11, 2017 at 12:50 PM, XXX ZZZ  wrote:
>
> So I'm starting to play with sync pool on a program that needs to allocate a
> ton of short lived objects per server request. Performance seems to be
> better when using sync pool however I've noticed that upon releasing the
> object and then retrieving it again, will produce a "new object" with "old
> request data". The solution for this would be to reset the object
> values/structs to 0, however I feel this will kinda defeat the purpose of
> using sync pool. After all, we will always be creating new objects.

Yes, if you use sync.Pool, you must re-initialize any object you get
from the pool, or you must restore any object you store in the pool
back to the initial state.  That is unavoidable.


> Given that sync pool is used to avoid overhead when creating a lot of
> elements, i would assume that I'm missing something here. Could anyone
> please shred some light on this?

That's not quite what sync.Pool is for.  sync.Pool is useful for
objects whose lifetime is bounded by a single operation, when there
can be parallel operations, when the number of parallel operations
varies significantly.  In such a case sync.Pool provides a cache that
lets you decrease allocation cost.  It's just one technique for
decreasing allocation cost, and there are several others.  Most
obviously, if the number of parallel operations does not vary
significantly, a freelist is a simpler and more effective technique.

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: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Frank Ruiz
Thank you Alex. 

To further clarify, what I am trying to do is create factory methods that 
return a common interface. In a nutshell, I am trying to create 
constructors that take a common argument.

As it stands, the parameter I specify is very specific (function with a 
pointer to a struct):

opts …func(*procStruct)

So end goal is to try to generalize the parameter (if possible), so when I 
add more factory functions I can associate them with a particular type 
known as plugin.

Also, thanks for the link.. going to take a look.


On Wednesday, October 11, 2017 at 12:22:55 PM UTC-7, Alex Buchanan wrote:
>
> I'm not sure I understand the example, but have you seen the grpc 
> library's use of options? For more type safety, you could define an 
> interface such as type PluginOpt interface { pluginOpt() }.
>
> https://godoc.org/google.golang.org/grpc#CallOption
>
> On Wednesday, October 11, 2017 at 11:23:16 AM UTC-7, Frank Ruiz wrote:
>>
>> Greetings,
>>
>> Was hoping to solicit some feedback on utilizing functional options in 
>> conjunction with factory methods.
>>
>> I currently have the following function:
>>
>> func ProcPlugin(opts …func(*procStruct){
>> p := defaulProc
>> for _, opt := range opts {
>> opt(&p)
>> }
>> return &p, nil
>> }
>>
>> I am now trying to generalize things (as I will be creating more factory 
>> functions), and I'm trying to determine if this is the most optimal way to 
>> represent the logic above.
>>
>> type PluginFactory func(opts ...interface{}) (Plugin, error)
>>
>> func NewProcPlugin(opts ...interface{}) (Plugin, error) {
>> p := defaulProc
>> for _, opt := range opts {
>> opt(&p)
>> }
>> return &p, nil
>> }
>>
>> Any feedback would be much appreciated. Please let me know if more 
>> context is required.
>>
>> Thank you!
>>
>

-- 
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] Sync pool old data

2017-10-11 Thread XXX ZZZ
Hello,

So I'm starting to play with sync pool on a program that needs to allocate 
a ton of short lived objects per server request. Performance seems to be 
better when using sync pool however I've noticed that upon releasing the 
object and then retrieving it again, will produce a "new object" with "old 
request data". The solution for this would be to reset the object 
values/structs to 0, however I feel this will kinda defeat the purpose of 
using sync pool. After all, we will always be creating new objects. 

Given that sync pool is used to avoid overhead when creating a lot of 
elements, i would assume that I'm missing something here. Could anyone 
please shred some light on this?

package main

import(
"sync"
"fmt"
)
type struct1 struct{
  obj1  struct2
  obj2  struct3
}

type struct2 struct{
   a string
}

type struct3 struct{
  a string
}


func AcquireStruct1() *struct1 {
return struct1pool.Get().(*struct1)
}
func ReleaseStruct1(u *struct1 ) {
//u.Reset()
struct1pool.Put(u)
}
var struct1pool= &sync.Pool{
New: func() interface{} {
a:=&struct1{}
return a
},
}

func main(){
  a:=AcquireStruct1()
  a.obj1.a="a"
  a.obj2.a="a"
  ReleaseStruct1(a)

  a=AcquireStruct1()
  fmt.Printf("%+v", a) // this outputs the data assigned to the first object
}
}

https://play.golang.org/p/JHHdwG1aqc

Thanks in advance.

-- 
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: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Alex Buchanan
I'm not sure I understand the example, but have you seen the grpc library's 
use of options? For more type safety, you could define an interface such as 
type PluginOpt interface { pluginOpt() }.

https://godoc.org/google.golang.org/grpc#CallOption

On Wednesday, October 11, 2017 at 11:23:16 AM UTC-7, Frank Ruiz wrote:
>
> Greetings,
>
> Was hoping to solicit some feedback on utilizing functional options in 
> conjunction with factory methods.
>
> I currently have the following function:
>
> func ProcPlugin(opts …func(*procStruct){
> p := defaulProc
> for _, opt := range opts {
> opt(&p)
> }
> return &p, nil
> }
>
> I am now trying to generalize things (as I will be creating more factory 
> functions), and I'm trying to determine if this is the most optimal way to 
> represent the logic above.
>
> type PluginFactory func(opts ...interface{}) (Plugin, error)
>
> func NewProcPlugin(opts ...interface{}) (Plugin, error) {
> p := defaulProc
> for _, opt := range opts {
> opt(&p)
> }
> return &p, nil
> }
>
> Any feedback would be much appreciated. Please let me know if more context 
> is required.
>
> Thank you!
>

-- 
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] Strange behavior when dealing with certain emojis

2017-10-11 Thread Michael Jones
...obviously! it suggests a part of technical life lacking the
prefix-decoding property.

If things are to EVER be that way generally (the clumpy aggregate way) it
would be remarkably better to always have prefix codes or have aggregate
"boxing symbols" as wrappers. this notion of a trailing modifier means that
you always need an LR(1) parser for the data stream.. which is high tax of
every kind.

On Wed, Oct 11, 2017 at 9:09 AM, as  wrote:

> >which puts a keycap symbol around the previous character
>
> Something about this sentence disturbs me.
>
>
> On Wednesday, October 11, 2017 at 3:36:16 AM UTC-7, Ian Davis wrote:
>>
>>
>> On Wed, 11 Oct 2017, at 11:16 AM, Gianguido Sorà wrote:
>>
>> Uhm, so the Replacer sees it as two separate entities, and replaces the
>> part of the composite that matches one of the cases.
>>
>>
>> Sort of. The emoji is really just the "\xE2\x83\xA3" part (or
>> "\U20e3") which puts a keycap symbol around the previous character. The
>> "\x32" is just the digit "2".
>>
>>
>> What could I do to make the Replacer ignore UTF-8 composites? Is that
>> even possible or should I handle the presence of these empty square boxes
>> after the substitution phase?
>>
>>
>>
>> Depends on what you are trying to achieve. You could replace the
>> "\x32\xE2\x83\xA3" sequence with something else first, then do your actual
>> replacement and restore the original after.
>>
>>
>> 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.
>



-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] Task scheduler as a library?

2017-10-11 Thread Alex Buchanan
Hey all,

In Funnel (a distributed task toolkit) we're sort of dancing around having 
a full-on scheduler. We have a scheduler that has grown from development 
util, to prototype, to something we actually use, but it's missing many of 
the features you'd want in production. Mostly we aim to delegate scheduling 
to another application (SGE, Slurm, AWS Batch, Kubernetes, etc), but having 
a built-in ability to schedule tasks without extra infrastructure is 
undeniably attractive.

Writing a scheduler is one of those things people warn you away from 
though. I wish there was a solid library we could embed, but I haven't 
found anything.

I wanted to get some opinions from this community. Do you know of any 
scheduling libraries? Do you think having scheduling built in is a good 
idea? A bad idea? Should we keep chipping away at it? Would people be 
interested in a standalone scheduling library, or is this problem 
inherently too complex to be adequately captured in library form?

Thanks!

Funnel: https://github.com/ohsu-comp-bio/funnel

-- 
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] How to covert simple RPC Call in Python to Go?

2017-10-11 Thread Justin Israel
On Wed, Oct 11, 2017, 9:51 AM Christian LeMoussel  wrote:

>
> connections.send(s, "getwork", 10)
>
> I searched a little bit more and here is in Python send() function
>
> def send(sdef, data, slen):
> sdef.setblocking(0)
>
> sdef.sendall(str(len(str(json.dumps(data.encode("utf-8"
> ).zfill(slen))
> sdef.sendall(str(json.dumps(data)).encode("utf-8"))
>
> Unfortunately, I don't know Python. the challenge is to rewrite the send 
> function
> in Go.
>

This code is converting the data to json twice.

The first time it converts it to get the length of the json string, and pad
it out to the expected length (10).

The second send converts it again and just sends the encoded json string.

Your Go version would just want to encode your data as json, send and first
send the length of it:

// Some Data
data := Data{"Foo"}
enc, err := json.Marshal(data)
if err != nil {
panic(err)
}

size := fmt.Sprintf("%010d", len(data) )

// send size
// send enc


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


[go-nuts] What is the best way to represent functional options within factory methods?

2017-10-11 Thread Frank Ruiz
Greetings,

Was hoping to solicit some feedback on utilizing functional options in 
conjunction with factory methods.

I currently have the following function:

func ProcPlugin(opts …func(*procStruct){
p := defaulProc
for _, opt := range opts {
opt(&p)
}
return &p, nil
}

I am now trying to generalize things (as I will be creating more factory 
functions), and I'm trying to determine if this is the most optimal way to 
represent the logic above.

type PluginFactory func(opts ...interface{}) (Plugin, error)

func NewProcPlugin(opts ...interface{}) (Plugin, error) {
p := defaulProc
for _, opt := range opts {
opt(&p)
}
return &p, nil
}

Any feedback would be much appreciated. Please let me know if more context 
is required.

Thank you!

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Tamás Gulácsi
WSL is a (nice) hack with rough edges: you can invoke Windows applications 
(go.exe) from that bash, or install the Linux go under WSL, and have "go" as 
under Linux.

-- 
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] Strange behavior when dealing with certain emojis

2017-10-11 Thread as
>which puts a keycap symbol around the previous character

Something about this sentence disturbs me.

On Wednesday, October 11, 2017 at 3:36:16 AM UTC-7, Ian Davis wrote:
>
>
> On Wed, 11 Oct 2017, at 11:16 AM, Gianguido Sorà wrote:
>
> Uhm, so the Replacer sees it as two separate entities, and replaces the 
> part of the composite that matches one of the cases.
>
>
> Sort of. The emoji is really just the "\xE2\x83\xA3" part (or 
> "\U20e3") which puts a keycap symbol around the previous character. The 
> "\x32" is just the digit "2".
>
>
> What could I do to make the Replacer ignore UTF-8 composites? Is that even 
> possible or should I handle the presence of these empty square boxes after 
> the substitution phase?
>
>
>
> Depends on what you are trying to achieve. You could replace the 
> "\x32\xE2\x83\xA3" sequence with something else first, then do your actual 
> replacement and restore the original after.
>
>
> 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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Pat Farrell
On Wednesday, October 11, 2017 at 4:12:45 AM UTC-4, brainman wrote:
>
> > On Wednesday, 11 October 2017 16:04:28 UTC+11, Pat Farrell wrote:
> > 1) is the standard documentation wrong/out of date?
>
> What documentation are you referring to? Did you read 
> https://golang.org/doc/code.html ?
>


https://golang.org/doc/install

 

> > 2) how do I get the go build process to create a hello.exe rather than 
> go.exe?
>
> I suspect Go uses your current directory to name your output file. Read 
> https://golang.org/doc/code.html how to organize your Go code. You could 
> also use -o flag to provide whatever output file name you like, for example 
> "go build -o hello.exe".
>

I'll try that.
 

> > 3) how do I get the bash shell to let me just type 'go build' like we 
> all want?
>
> What bash shell are you talking about? Windows does not come with bash 
> shell. If you have Linux install, then you should install Linux version of 
> Go, not Windows version of Go.
>

You are way out of date on this one. After decades of providing a terrible 
shell, Microsoft has decided to provide a real bash shell with real Ubuntu 
utilities.   It has apt-get and is pretty nice, way better than the old cmd 
shell
https://msdn.microsoft.com/en-us/commandline/wsl/about

Still need to figure out how to make a simple 'go build' work
rather than having to enter 'go.exe build' 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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Scope of variables with closures

2017-10-11 Thread etienne . daspe
Thank you for the explanations, I understand it better now.

Etienne

On Wednesday, 11 October 2017 14:26:56 UTC+2, Marvin Renich wrote:
>
> * Marvin Renich > [171011 08:19]: 
> > > >> > //func fibo2() func() (x int) { 
> >   ^ 
> > 
> > Here, x is a placeholder name within a type literal; it is not within 
> > the scope of fibo. 
>^ 
>
> Typo; should be fibo2. 
>
> ...Marvin 
>
>

-- 
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] Scope of variables with closures

2017-10-11 Thread Marvin Renich
* Marvin Renich  [171011 08:19]:
> > >> > //func fibo2() func() (x int) { 
>   ^
> 
> Here, x is a placeholder name within a type literal; it is not within
> the scope of fibo.
   ^

Typo; should be fibo2.

...Marvin

-- 
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] Scope of variables with closures

2017-10-11 Thread Marvin Renich
* etienne.da...@gmail.com  [171011 03:14]:
> I was thinking of your answer, and I don't understand when you say:
> 
> > within a func type literal such as `func() (x int)`, the scope of the 
> > parameters and results is restricted to the type literal itself.
> >
> Because the following code works, so the scope of a parameter is different 
> than the scope of a result.
> 
> const N = 10
> 
> func main() {
> f := fibo(0)
> for i := 0; i < N; i++ {
> fmt.Println(f())
> }
> }
> 
> func fibo(x int) func() int {
^

Here, x is in the scope of fibo and during execution of fibo exists as a
variable with that name.  Within fibo it can be bound in a closure
created by fibo.

> y := 1
> return func() int {
> defer func() { x, y = y, x+y }()
> return x
> }
> }
> 
> On Tuesday, 10 October 2017 17:08:49 UTC+2, Etienne Daspe wrote:
> > On Tuesday, 10 October 2017 16:58:43 UTC+2, Ian Lance Taylor wrote:
> >> On Tue, Oct 10, 2017 at 7:22 AM,   wrote: 
> >> > // fibo2 doesn't compile because x is undefined in the function 
> >> returned. 
> >> > //func fibo2() func() (x int) { 
  ^

Here, x is a placeholder name within a type literal; it is not within
the scope of fibo.  This could be rewritten as:

type result func() (x int)
func fibo2() result {

Note that x is neither an argument nor a result of fibo2 (either way the
code is written).  The name x in fibo2 is part of the description of the
type of the result of fibo2, it is not the name of an argument or result
of fibo2.  This is what Ian was saying below.

> >> > //y := 1 
> >> > //return func() int { 
> >> > //defer func() { x, y = y, x+y }() 
> >> > //return x 
> >> > //} 
> >> > //} 
> >>
> >> In the commented out code, x is a result variable, but only for 
> >> `func() (x int)`.  x is not a result variable for fibo2. 
> >>
> >> To put it differently, within a func type literal such as `func() (x 
> >> int)`, the scope of the parameters and results is restricted to the 
> >> type literal itself. 
> >>
> >> Ian 

...Marvin

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread Wojciech S. Czarnecki
On Wed, 11 Oct 2017 01:12:45 -0700 (PDT)
brainman  wrote:

> What bash shell are you talking about? Windows does not come
> with bash shell.

Ooops, now it comes:
https://msdn.microsoft.com/en-us/commandline/wsl/about.

> If you have Linux install, then you should install Linux version of 
> Go, not Windows version of Go.

OP got this hint from the Windows (> sudo apt-get install gccgo).
This is a new scenario for beginners and Go docs are not aware of it.

-- 
Wojciech S. Czarnecki
 << ^oo^ >> OHIR-RIPE

-- 
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] A few go 2 suggestions

2017-10-11 Thread Scott Cotton
The difference is that go-routine level defers could be added further down 
the call stack and so could
reference objects not visible in the calling "go ...()" scope.

So it could simplify the messy task of cleaning up goroutines (implemented 
now by eg Context, tomb, etc)

No need to identiy goroutines to implement this, as far as I know.

Best
Scott




Le mercredi 11 octobre 2017 01:15:48 UTC+2, kortschak a écrit :
>
> On Tue, 2017-10-10 at 06:13 -0700, Scott Cotton wrote: 
> > 1. "defer go"   extend defers to work on goroutine exit with 
> > mechanism just  
> > like defer, but if we say "defer go f()" 
> > instead of "defer f()" then we run on goroutine exit.  Very big gains 
> > for  
> > scaling here IMHO. 
>
>
> How is this different to... 
>
> go func() { 
> defer func() {...}() 
> ... 
> }() 
>
> or do you mean (the probably less useful) 
>
> defer func() { 
> ... 
> go func() {...}() 
> ... 
> }() 
>
> ...? 
>
> As you can see, both of these are already expressible. Maybe you mean 
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis

On Wed, 11 Oct 2017, at 11:16 AM, Gianguido Sorà wrote:
> Uhm, so the Replacer sees it as two separate entities, and replaces
> the part of the composite that matches one of the cases.
Sort of. The emoji is really just the "\xE2\x83\xA3" part (or
"\U20e3") which puts a keycap symbol around the previous character.
The "\x32" is just the digit "2".
> 
> What could I do to make the Replacer ignore UTF-8 composites? Is that
> even possible or should I handle the presence of these empty square
> boxes after the substitution phase?

Depends on what you are trying to achieve. You could replace the
"\x32\xE2\x83\xA3" sequence with something else first, then do your
actual replacement and restore the original after.

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] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis
On Wed, 11 Oct 2017, at 10:33 AM, Ian Davis wrote:
> 
> On Wed, 11 Oct 2017, at 09:57 AM, Gianguido Sorà wrote:
>> 
>> I'm writing a small utility which uses a strings.Replacer to process
>> some substitutions in some strings; these strings contains UTF-8
>> characters as well as emojis.>> 
>> Here you can find a playground with an example:
>> https://play.golang.org/p/gdfZ_zGGiO>> 
>> As you can see from the playground, the occurrence of "2" has been
>> replaced with the string "altered" into the emoji itself, even though
>> the hex representation of it is not directly listed in the Replacer.>> 
>> What could I do to prevent this from happening?
> 
> At first glance this looks like a bug in strings.Replacer. If the
> string you are replacing is a single byte character then NewReplacer
> uses a byteStringReplacer which treats the target as a byte array. I
> suggest opening an issue here https://github.com/golang/go/issues
After a bit more thought, the reason why the replacement happens is
because the emoji you are using is a composite that combines the keycap
image with the number 2. You can see it in this example which shows
various equivalent forms of the emoji:
https://play.golang.org/p/HhaNuZ3JZM

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: Speeding up a concurrent "simple" web server

2017-10-11 Thread lee
Thanks Dave,

I just used "hey" (I didn't realise that ab was quite so bad!), it looks 
much better!

Summary:

  Total: 36.1492 secs

  Slowest: 0.3418 secs

  Fastest: 0.0002 secs

  Average: 0.0349 secs

  Requests/sec: 2766.3147

  Total data: 459420 bytes

  Size/request: 45942 bytes


Response time histogram:

  0.000 [1] |

  0.034 [66122] |

  0.068 [14786] |∎

  0.103 [9836] |∎∎

  0.137 [4753] |∎∎∎

  0.171 [2261] |∎

  0.205 [1425] |∎

  0.239 [551] |

  0.273 [178] |

  0.308 [79] |

  0.342 [8] |


Latency distribution:

  10% in 0.0022 secs

  25% in 0.0031 secs

  50% in 0.0124 secs

  75% in 0.0520 secs

  90% in 0.0990 secs

  95% in 0.1318 secs

  99% in 0.2002 secs


Details (average, fastest, slowest):

  DNS+dialup: 0. secs, 0. secs, 0.0118 secs

  DNS-lookup: 0. secs, 0. secs, 0.0093 secs

  req write: 0. secs, 0. secs, 0.0040 secs

  resp wait: 0.0347 secs, 0.0001 secs, 0.3417 secs

  resp read: 0.0002 secs, 0. secs, 0.0879 secs


Status code distribution:

  [200] 10 responses

On Tuesday, October 10, 2017 at 9:22:57 PM UTC+1, Dave Cheney wrote:
>
> Looking at the ab output I think shell escaping has busted the query you 
> pass to your request. 
>
> Nit: an is widely considered by gophers to be unreliable, you might want 
> to try other tools like wrk, hey (née boom), or siege. 

-- 
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] Strange behavior when dealing with certain emojis

2017-10-11 Thread Jan Mercl
On Wed, Oct 11, 2017 at 11:34 AM Ian Davis  wrote:

> At first glance this looks like a bug in strings.Replacer.

What bug do you mean? https://play.golang.org/p/0DBwWt2TU9

-- 

-j

-- 
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] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis

On Wed, 11 Oct 2017, at 09:57 AM, Gianguido Sorà wrote:
> 
> I'm writing a small utility which uses a strings.Replacer to process
> some substitutions in some strings; these strings contains UTF-8
> characters as well as emojis.> 
> Here you can find a playground with an example:
> https://play.golang.org/p/gdfZ_zGGiO> 
> As you can see from the playground, the occurrence of "2" has been
> replaced with the string "altered" into the emoji itself, even though
> the hex representation of it is not directly listed in the Replacer.> 
> What could I do to prevent this from happening?

At first glance this looks like a bug in strings.Replacer. If the string
you are replacing is a single byte character then NewReplacer uses a
byteStringReplacer which treats the target as a byte array. I  suggest
opening an issue here https://github.com/golang/go/issues
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] Strange behavior when dealing with certain emojis

2017-10-11 Thread Jan Mercl
On Wed, Oct 11, 2017 at 10:58 AM Gianguido Sorà  wrote:

WAI: "\x32" == "2"



-- 

-j

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread brainman
> On Wednesday, 11 October 2017 16:04:28 UTC+11, Pat Farrell wrote:

> 1) is the standard documentation wrong/out of date?

What documentation are you referring to? Did you 
read https://golang.org/doc/code.html ?

> 2) how do I get the go build process to create a hello.exe rather than 
go.exe?

I suspect Go uses your current directory to name your output file. 
Read https://golang.org/doc/code.html how to organize your Go code. You 
could also use -o flag to provide whatever output file name you like, for 
example "go build -o hello.exe".

> 3) how do I get the bash shell to let me just type 'go build' like we all 
want?

What bash shell are you talking about? Windows does not come with bash 
shell. If you have Linux install, then you should install Linux version of 
Go, not Windows version of Go.

I hope it helps.

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.


[go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Christian LeMoussel
It's OK.Thank you very much.

-- 
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] Scope of variables with closures

2017-10-11 Thread etienne . daspe
I was thinking of your answer, and I don't understand when you say:

> within a func type literal such as `func() (x int)`, the scope of the 
> parameters and results is restricted to the type literal itself.
>
Because the following code works, so the scope of a parameter is different 
than the scope of a result.

const N = 10

func main() {
f := fibo(0)
for i := 0; i < N; i++ {
fmt.Println(f())
}
}

func fibo(x int) func() int {
y := 1
return func() int {
defer func() { x, y = y, x+y }()
return x
}
}

On Tuesday, 10 October 2017 17:08:49 UTC+2, Etienne Daspe wrote:
>
> Thank you for the answer :)
>
> Etienne
>
> On Tuesday, 10 October 2017 16:58:43 UTC+2, Ian Lance Taylor wrote:
>>
>> On Tue, Oct 10, 2017 at 7:22 AM,   wrote: 
>> > 
>> > I'm trying to understand the scope of variables when using closures. 
>> > I wrote a simple program to compute fibonacci sequence with a closure 
>> (see 
>> > below). 
>> > Knowing that named return variables are initialized to 0 (when their 
>> type is 
>> > int), I tried to simplify my function ; but it doesn't compile, saying 
>> that 
>> > x is undefined. 
>> > I conclude that the scope of a return variable isn't the same as a 
>> "classic" 
>> > variable, but I don't understand why. 
>> > 
>> > Can you explain me the difference of scope between these two kind of 
>> > variables please? And the reason why they don't share the same scope? 
>> > 
>> > My program in the Go Playground: https://play.golang.org/p/KPWK9xoNNZ 
>> > 
>> > 
>> > const N = 10 
>> > 
>> > func main() { 
>> > f := fibo() 
>> > for i := 0; i < N; i++ { 
>> > fmt.Println(f()) 
>> > } 
>> > } 
>> > 
>> > func fibo() func() int { 
>> > x, y := 0, 1 
>> > return func() int { 
>> > defer func() { x, y = y, x+y }() 
>> > return x 
>> > } 
>> > } 
>> > 
>> > // fibo2 doesn't compile because x is undefined in the function 
>> returned. 
>> > //func fibo2() func() (x int) { 
>> > //y := 1 
>> > //return func() int { 
>> > //defer func() { x, y = y, x+y }() 
>> > //return x 
>> > //} 
>> > //} 
>>
>> In the commented out code, x is a result variable, but only for 
>> `func() (x int)`.  x is not a result variable for fibo2. 
>>
>> To put it differently, within a func type literal such as `func() (x 
>> int)`, the scope of the parameters and results is restricted to the 
>> type literal itself. 
>>
>> 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: How to convert JSON message to Go struct

2017-10-11 Thread Tamás Gulácsi
s1, i1, s2, i2 := workpack[0][0].(string), int(workpack[0][1].(float64)), 
workpack[0][2].(string), int(workpack[0][3].(float64))

2017. október 11., szerda 9:02:17 UTC+2 időpontban Christian LeMoussel a 
következőt írta:
>
> Ok but how can I acces  four values?
>
> I do this 
> segments = 
> []byte("[[\"19c87d4ddf59160406821ca102aa4f49846ecf5ac3d41d2007883834\", 
> 75, \"b54317cb538c6b3a5ae8b84f8b53c83652037038ad8ad6bef4c8b43a\", 101]]")
> var workPack [][]interface{}
> err = json.Unmarshal(segments, &workPack)
> checkError(err)
>
>
>

-- 
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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-11 Thread as
A Go project is organized as a file system. The directory your go source 
files reside in indicate the name of the executable created with go build.

On Tuesday, October 10, 2017 at 10:04:28 PM UTC-7, Pat Farrell wrote:
>
> I've installed the go 1.9 binary distribution on my windows 10 laptop. 
> I just let the install do the defaults. (in addition to learning go, I'm 
> trying to see if I can live with 
> bash under Windows, or if I have to reboot to a linux distro to avoid 
> going crazy, that is a separate topic)
>
> in the cmd shell
> 'go build' works, but creates a file go.exe that when run, displays hello 
> world
> it does not create the expected hello.exe
>
> in the bash shell, 'go build' does not work, it whines that 'go' is not a 
> program
>
> The program 'go' is currently not installed. You can install it by typing:
> sudo apt-get install gccgo-go
>
>
>
> but 'go.exe build' does create a local go.exe which executes and displays 
> the expected hello world.
>
> Which raises a couple of questions:
>
> 1) is the standard documentation wrong/out of date?
> 2) how do I get the go build process to create a hello.exe rather than 
> go.exe?
> 3) how do I get the bash shell to let me just type 'go build' like we all 
> want?
>
>
>
>

-- 
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: How to convert JSON message to Go struct

2017-10-11 Thread Gianguido Sorà
You should operate type assertion by iterating on the array.




My advice is to write a "Work" struct with all the field you need, and create 
an instance for each iteration of the outer array.




This way you'll have a nice representation of a "Work" package for each inner 
array.




I cannot provide an example right now but by reading the docs this should be 
trivial. 




On Wed, Oct 11, 2017 at 9:02 AM +0200, "Christian LeMoussel"  
wrote:










Ok but how can I acces  four values?

I do this 
segments = 
[]byte("[[\"19c87d4ddf59160406821ca102aa4f49846ecf5ac3d41d2007883834\", 75, 
\"b54317cb538c6b3a5ae8b84f8b53c83652037038ad8ad6bef4c8b43a\", 101]]")var 
workPack [][]interface{}err = json.Unmarshal(segments, &workPack)
checkError(err)







-- 

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.


[go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Christian LeMoussel
Ok but how can I acces  four values?

I do this 
segments = 
[]byte("[[\"19c87d4ddf59160406821ca102aa4f49846ecf5ac3d41d2007883834\", 
75, \"b54317cb538c6b3a5ae8b84f8b53c83652037038ad8ad6bef4c8b43a\", 101]]")
var workPack [][]interface{}
err = json.Unmarshal(segments, &workPack)
checkError(err)


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