Re: [go-nuts] Gomobile and SAF

2017-10-12 Thread Jakob Borg
On 12 Oct 2017, at 23:43, audrius.butkevic...@gmail.com wrote:
> 
> Your example has a MainActivity.java.
> As I said, this is a Go application, and as it stands it has no Java, so it 
> doesn't have (and doesn't intend to have) a main activity.
> Also, your initialization (Hello.initContentProvider) happens from Java (not 
> from Go), so my question is still unanswered of how do do all of this purely 
> from the Go side without reverse bindings.

Maybe a solution in this case is to refactor the Go program to be a library 
(just moving package main to package app, and main.main() -> app.Run() or 
something) and then using dependency injection from the Java side.

//jb

-- 
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-12 Thread Pat Farrell

On Thursday, October 12, 2017 at 8:31:52 PM UTC-4, Gerald wrote:
>
> The MSI is a Windows application, whereas apt-get would install the 
> Linux binary of go. 
>
> WSL has you actually running Linux binaries on Windows unless you 
> specifically go and choose a Windows executable. 
>

The MSI file triggers a Windows application, sure. But is the actual go 
binary different?
Its possible to make a Posix compliant system call on nearly any operating 
system. Posix was
designed to let the US Government require Unix, back when Unix was special. 
But the basic functions
that most of us call Unix or Linux system calls are trivial in any 
operating system. Probably even Plan-9

There is a lot less to making bash, and apt-get run on any operating system 
than many folks think

I may have to do both installs and do a shasum on the files.
 

-- 
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-12 Thread Gerald Henriksen
On Thu, 12 Oct 2017 00:03:41 -0400, you wrote:

>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

There is a difference.

The MSI is a Windows application, whereas apt-get would install the
Linux binary of go.

WSL has you actually running Linux binaries on Windows unless you
specifically go and choose a Windows executable.

-- 
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] Get method/function parameter types with reflect?

2017-10-12 Thread Trig
Thank you!  You lead me in the right direction.  It was .In() and .Out() I 
was looking for.  Appreciate it, Ian.

On Thursday, October 12, 2017 at 6:12:41 PM UTC-5, Ian Lance Taylor wrote:
>
> On Thu, Oct 12, 2017 at 3:03 PM, burpswangy  > wrote: 
> > 
> > Is it possible to use the reflect package to get the parameter/function 
> > types for a specified method/function? 
>
> I'm not sure precisely what you are asking, but the answer is probably 
> yes.  Start with something like reflect.ValueOf(myFunction).Type(). 
>
> 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] Get method/function parameter types with reflect?

2017-10-12 Thread Ian Lance Taylor
On Thu, Oct 12, 2017 at 3:03 PM, burpswangy  wrote:
>
> Is it possible to use the reflect package to get the parameter/function
> types for a specified method/function?

I'm not sure precisely what you are asking, but the answer is probably
yes.  Start with something like reflect.ValueOf(myFunction).Type().

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] Get method/function parameter types with reflect?

2017-10-12 Thread burpswangy
Is it possible to use the reflect package to get the parameter/function 
types for a specified method/function?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Cgo profiles and ExternalCode

2017-10-12 Thread andrey mirtchovski
Thanks, this helped and worked right off the bat.

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

2017-10-12 Thread Daniel Whitenack
Hi Alex,

Thanks! Appreciate the kind words. Reach out any time if I can help with
any of your use cases, answer questions, etc.

Best,
Daniel

On Wed, Oct 11, 2017 at 10:33 PM, Alex Buchanan 
wrote:

> 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-sc
>> ratch-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 a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/kdpMF44SC4c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Daniel Whitenack
Data Scientist/Engineer
datadan.io
d...@datadan.io
@dwhitena 

-- 
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-12 Thread lee
That is good to know thanks.  Just shows how different it is!

On Thursday, October 12, 2017 at 1:03:37 PM UTC+1, Slawomir Pryczek wrote:
>
> AB is using HTTP/1.0, so it isn't able to do keepalives and it may be the 
> case that you're really benchmarking your TCP stack, instead of your 
> webserver... as TCP connect is probably the bottleneck here :) Not sure how 
> it works under the hood, but enabling tcp_reuse, and tcp_recycle might 
> improve the results for ab, which are irrelevant anyway.
>
> Basically this seem related to HTTP/1.0 being outdated, so it isn't able 
> to handle large amount of connections between 2 points well. We had same 
> characteristics, seen in logs - untill we enabled keepalive and HTTP/1.1 
> for our micro-services.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Cgo profiles and ExternalCode

2017-10-12 Thread andrey mirtchovski
Is there any way, an option or an argument, that would allow me to
unwind the stack on the CGO side of a profile better? Right now I'm
looking at stacks that unwind only the top function, see example. This
happens on both linux and macOS.

My other option is to link gperftools into the go binary, but it's too
big enough as it is. Any advice is welcome.

-- 
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-12 Thread 'Bryan Mills' via golang-nuts
On Wednesday, October 11, 2017 at 4:03:30 PM UTC-4, Ian Lance Taylor wrote:
>
> if the number of parallel operations does not vary 
> significantly, a freelist is a simpler and more effective technique. 
>

A freelist might be simpler, but it isn't necessarily more effective. 
sync.Pool combines two (non-orthogonal) properties: thread-local allocation 
and weak references.

If the number of operations does not vary, the weak references don't matter 
much, but the thread-local allocation might. If many operations occur in 
parallel on a system with many CPU cores, a freelist can suffer from 
significant cache contention, whereas a sync.Pool generally will not. (See 
also https://golang.org/issue/18802.)

That said, Go's allocator is fairly thread-local to begin with, so if 
you're explicitly zeroing out the objects before reusing them anyway, 
sync.Pool should provide very little benefit over simply allocating a new 
object for each operation. (That is especially true when the objects are 
small, and thus more likely to be satisfiable out of memory the thread has 
already obtained.)

-- 
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 learn golang web development

2017-10-12 Thread Shawn Milochik
Start here:
https://golang.org/doc/articles/wiki/

And, of course, familiarize yourself with the language here:
https://tour.golang.org/welcome/1

-- 
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-12 Thread Slawomir Pryczek
AB is using HTTP/1.0, so it isn't able to do keepalives and it may be the 
case that you're really benchmarking your TCP stack, instead of your 
webserver... as TCP connect is probably the bottleneck here :) Not sure how 
it works under the hood, but enabling tcp_reuse, and tcp_recycle might 
improve the results for ab, which are irrelevant anyway.

Basically this seem related to HTTP/1.0 being outdated, so it isn't able to 
handle large amount of connections between 2 points well. We had same 
characteristics, seen in logs - untill we enabled keepalive and HTTP/1.1 
for our micro-services.

-- 
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] Why go does't have NullInt type on database/sql?

2017-10-12 Thread Jan Mercl
On Thu, Oct 12, 2017 at 2:38 AM 高橋誠二  wrote:

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

That does not work accross architectures.

> What is the reason?

The driver model has only one integer type - int64. NullInt would not be
able to handle 64 bit ints on 32-bit architectures.

-- 

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

2017-10-12 Thread as

>  does it cope with characters whose bounding  boxes overlap

I remember that being an issue with an older prototype of this library, 
specifically with runs of tightly grouped glyphs like `ff` and the 
GoRegular font. I haven't experienced any of the glitches from glyphs with 
overlapping bounding boxes lately (using GoRegular), which means that bug 
was fixed inadvertently or is hibernating in wait for the right font. 
Unfortunately none of the current tests use a proportional font, so its 
difficult to tell. The best answer is that it doesn't handle that case 
explicitly, the worst answer is maybe it does and I just forgot about it.
 

On Wednesday, October 11, 2017 at 7:17:01 PM UTC-7, Nigel Tao wrote:
>
> On Wed, Oct 11, 2017 at 2:30 PM, as  wrote: 
> > https://github.com/as/frame 
>
> Nice! 
>

Thanks!

On Wednesday, October 11, 2017 at 11:54:12 PM UTC-7, rog wrote:
>
> 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...@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: go on Windows 10 from the bash shell (and the cmd shell)

2017-10-12 Thread Brian Ketelsen
WSL works perfectly well for Go development.  It’s my primary dev environment   
Just treat it like Linux and you’ll be fine. 

-- 
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-12 Thread Elias Naur
Hi,

As I noted on the issue, you should avoid the reverse binding for now and use 
Go interfaces instead. The following change to the gomobile bind example 
demonstrates the technique:

diff --git 
a/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
 
b/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
index 47248d9..fce9a7b 100644
--- 
a/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
+++ 
b/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
@@ -11,6 +11,8 @@ import android.os.Bundle;
 import android.widget.TextView;
 
 import hello.Hello;
+import hello.ContentProvider;
+import hello.Writer;
 
 public class MainActivity extends Activity {
 
@@ -25,5 +27,16 @@ public class MainActivity extends Activity {
 // Call Go function.
 String greetings = Hello.greetings("Android and Gopher");
 mTextView.setText(greetings);
+
+   Hello.initContentProvider(new ContentProvider() {
+   @Override public Writer open(String name) throws 
Exception {
+   return new Writer() {
+   @Override public long write(byte[] 
data) throws Exception {
+   return 0;
+   }
+   };
+   }
+   });
+   Hello.useContentProvider();
 }
 }
diff --git a/example/bind/android/hello/build.gradle 
b/example/bind/android/hello/build.gradle
index 92fb0bd..11345e4 100644
--- a/example/bind/android/hello/build.gradle
+++ b/example/bind/android/hello/build.gradle
@@ -4,7 +4,7 @@
  */
 
 plugins {
-id "org.golang.mobile.bind" version "0.2.9"
+id "org.golang.mobile.bind" version "0.2.7"
 }
 
 gobind {
diff --git a/example/bind/hello/hello.go b/example/bind/hello/hello.go
index 2d98ff9..96301da 100644
--- a/example/bind/hello/hello.go
+++ b/example/bind/hello/hello.go
@@ -10,3 +10,28 @@ import "fmt"
 func Greetings(name string) string {
return fmt.Sprintf("Hello, %s!", name)
 }
+
+var contentProvider ContentProvider
+
+type ContentProvider interface {
+   Open(name string) (Writer, error)
+}
+
+type Writer interface {
+   Write(b []byte) (int, error)
+}
+
+func InitContentProvider(cp ContentProvider) {
+   contentProvider = cp
+}
+
+func UseContentProvider() {
+   w, err := contentProvider.Open("test")
+   if err != nil {
+   // handle error
+   }
+   _, err = w.Write([]byte("data"))
+   if err != nil {
+   // handle error
+   }
+}


The gobind plugin downgrade is https://github.com/golang/go/issues/21594.

 - elias

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