UI with browser window

I've been looking at the various UI options for Go with the ability to show and manipulate a web browser interface.

go-qml and gotk3 with go-webkit2 seem like the options. There's also cef2go but I need standard UI outside the browser window.

Qt is such a huge installation and gtk+webkit are separate projects. I'm not sure if these are the only options and what's best to learn.

Opinions requested. Thanks.

Refs:
https://github.com/go-qml/qml
https://github.com/conformal/gotk3
https://github.com/sourcegraph/go-webkit2
https://github.com/CzarekTomczak/cef2go


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
SauliusGurklys | 17 Sep 21:26 2014
Picon

http.Get() and "connection reset by peer" errors

Hello,

the small program below could be run as

./ program -url <someURL>

or

./ program -skipbody -url <someURL>

On my machine, running it without -skipbody parameter, in doGet() function, "ioutl.ReadAll()" is performed, which seems
to cause to keep open the connection (seen with "lsof | grep program") to http server, so every second http.Get() returns error:

Get <someURL>: read tcp <ip>:80: connection reset by peer

In web server log no such error requests are logged, so it seems that  these requests tries to reuse previous connection, which is closed.

If I add -skipbody parameter then no error occurs.

I'm using:
 * web server - nginx
 * OS - ubuntu 12.04
 * go version devel +b279bb7f7c3b Tue Sep 16 19:54:26 2014 -0700 linux/amd64

Am I doing something wrong? Or is it a bug of some net/* package?
Any comments?

package main

import (
   
"flag"
   
"io/ioutil"
   
"log"
   
"net/http"
   
"time"
)

var (
    skipBody
bool
    url      
string
)

func init
() {
    flag
.BoolVar(&skipBody, "skipbody", false, "skip body")
    flag
.StringVar(&url, "url", "", "url")
}

func main
() {

    flag
.Parse()

   
if url == "" {
        log
.Fatal("Need URL!")
   
}

    go func
(url string, skipBody bool) {
        i
:= 0
       
for {
            i
++
            log
.Printf("R #%d", i)
            err
:= doGet(url, skipBody)
           
if err != nil {
                log
.Println(err)
           
} else {
                log
.Println("OK")
           
}
            time
.Sleep(60 * time.Second)

       
}
   
}(url, skipBody)

    time
.Sleep(10 * time.Minute)
}

func doGet
(url string, skipBody bool) (err error) {

    resp
, err := http.Get(url)
   
if err != nil {
       
return
   
}
    defer resp
.Body.Close()

   
if skipBody {
       
return
   
}

    data
, err := ioutil.ReadAll(resp.Body)
   
if err != nil {
       
return
   
}

    log
.Printf("len(data) = %d ", len(data))
    time
.Sleep(5 * time.Second) // wait a little bit

   
return
}

Thanks,
--
Saulius

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Mauro Romano Trajber | 17 Sep 19:08 2014
Picon

HTTP headers that depends on the body

Hi,

Is there a efficient way to add HTTP headers that depends on the body without buffering? I mean, how can I add a Content-MD5 header, for example, without buffering the content to compute the hash at the end, just before write it on the wire? I know that once the body is written I cannot add headers anymore, but how Golang's net/http calculate the Content-Length since the total length will only be known after all body is written?
What's the most efficient way to add these headers?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Vasiliy Tolstov | 17 Sep 18:13 2014
Picon

listen on 0.0.0.0 port 80 on specific device

Hi. May be i'm misunderstanding , but i need to listen on 0.0.0.0:80
on each tap device, but i don't need to listen wildcarded on all
devices, In case of listenip i can after that bind socket to device,
but in case of listentcp i can't (i get error that address already
used).
Does it possible to convert IPConn to TCPConn that i can use in http.Serve?

-- 
Vasiliy Tolstov,
e-mail: v.tolstov@...
jabber: vase@...

--

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

makkalot | 17 Sep 15:27 2014
Picon

Convert chan of something to chan of interface{}

Hi,

I have that function with signature like : func MergeChannelsGeneric(cs 
[]<-chan interface{}) <-chan interface{}
and then want to write the type specific version which calls the one 
above : func MergeWorkerChans(workers map[string]Worker) <-chan [][]byte

I couldn't find a way to convert []<-chan [][]byte to [] <-chan 
interface{} and also the reverse operation is not possible : <-chan 
interface{} to <-chan [][]byte
Is there a way to accomplish this ?

Here is a snippet of what i'm doing :

     workerChans := make([]<-chan [][]byte, len(workers))
     genericChans := make([]<-chan interface{}, len(workers))

     i := 0
     for _, w := range workers {
         genericChans[i] = w.GetOutChan()
         i = i + 1
     }

I'm getting : cannot use w.GetOutChan() (type <-chan [][]byte) as type 
<-chan interface {} in assignment

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

Péter Szilágyi | 17 Sep 10:21 2014
Picon

Google calendar pishishing event?!

Hey all,

  Sorry for the off topic, but a phishing attack was just inserted into my Google calendar as an event and by looking at the other invites, it originates from the golang-nuts mailing list. At least the guy used the golang nuts email addresses for the invite. This is seriously not cool. I've no clue how or why Google calendar allows random events to be inserted into my personal calendar, but when I get a notification on my mobile for an event, and it turns out to be a phishing attack, I'm getting really angry. Anyone else here noticed this? Or any hints for disabling such idiocy from Google calendar?

Thanks,
  Peter

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Pablo Rozas Larraondo | 17 Sep 09:30 2014
Picon

Checking differences between two "exec.Cmd"

I have two variables containing exec.Cmd instances. If I print their values their content looks the same:

{/home/roz016/anaconda/bin/python [python /home/roz016/github/test/sleep.py 10] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> false [] [] [] [] <nil>}

One of the variables runs perfectly using the .Run() function whereas the other one returns an error. Is there a way of finding where the difference between these two variables comes from? or asked in a different way, is there a way of doing introspection of exec.Cmd variables?

Cheers,
Pablo

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Dalton Hubble | 17 Sep 08:37 2014
Picon

Interface design advice through a thread-safe map example

I wrote a simple thread-safe map[interface{}]interface{} struct with a lock (I realize lots of people have written these) and I think it raised some interesting questions for me. src: https://github.com/dghubble/safemap/blob/master/safemap.go docs: https://godoc.org/github.com/dghubble/safemap

I sought to make the Mapper interface the minimal essential features a custom thread-safe mapper type must have.

type Mapper interface {
Set(interface{}, interface{})
Get(interface{}) (interface{}, bool)
Delete(interface{})
Len() int
Keys() []interface{}
Values() []interface{}
}

I think it is fairly clear that Set, Get, and Delete are needed. Note that Get returns whether the key is present to be as similar as possible to builtin maps. Len() is needed so that the length can be read in a thread-safe way. Go for range loops over builtin maps have a nice feature that iterations over mutating maps are allowed https://groups.google.com/forum/#!topic/golang-nuts/rEmaoxi11_A. Custom types cannot be used with range and have no such property, so Keys() and Values() perform a for range iteration to construct a "snapshot" slice of keys or values. Without those two methods I believe you'd have to expose the internal map to allow a developer to iterate to get the keys or values.

What was excluded you ask? I've seen implementations with Check, IsEmpty, Clear, and other such convenience functions that are not strictly needed (that can all be accomplished with the Mapper interface I've defined) so I don't include them in Mapper.

1. Do you feel this is the minimal interface? What might you improve?

2. Are the Keys() and Values() implementations truly thread safe without the read lock? The spec seems to indicate yes.

3. Nothing about this interface guarantees thread safety. One could easily implement this with a wrapper around a builtin map (not thread-safe). Is it conventional to add a dummy method such as ThreadSafe() such that a method can require a thread-safe map? Or overkill?

Answers to any (or all) parts of the question you guys care to comment on would be really appreciated! Still learning this great language.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
magrathean | 17 Sep 05:33 2014
Picon

newbie query: file read

I have a simple text file of floats, each number on a line.

$ cat numbers
1
2
3

How do I read this file and create a slice of floats?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
yeer | 17 Sep 05:02 2014
Picon

Feature request for goimports, disable fixing imports in the path of $GOPATH/src, because it will be very slow when there are many local packages

Hi all.
I was trying to make a issue on https://github.com/bradfitz/goimports, however the issues entrance was closed, seems the goimports is now a tool of go.tools.
So I follow the rules of http://golang.org/doc/contribute.html and ask my question here.

My problem is when there are many packages in my local $GOPATH/src, every time I execute the goimports command for a non-standard pkg, it turns very slow.

here is my experimental example:

➜    time goimports main.go
// Package main
package main

import (
"fmt"
"log"
)

func main() {
nonexists.Hell
log.Println("xx")
fmt.Println("xx")
}
goimports main.go  3.24s user 100.82s system 330% cpu 31.523 total


And my directories number on $GOPATH is

➜   find $GOPATH -type d  | wc -l
   30499
➜   find $GOPATH/src -type d  | wc -l
   30373

Anyone who encounter the same problem or it is just my special case? 


Maybe here are some directions to solve my problems. Please let me know if there are already solutions. 

1. Just provide an option to disable the $GOPATH searching process.

2. Improve the fiximport speed. Searching every time costs highly, maybe introducing a cache, by some mru algorithms?

3. Another issue is when there are more than 1 pkg fits the package name in the non-standard path, goimports will just import one of them, which may be unexpected, need a better validation? 



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Eric Z | 17 Sep 02:45 2014
Picon

cgo: is it safe to malloc and free in seperate c functions

Hello Golang-nuts,

This might sounds simple. I am trying to understand how go manages the memory allocated by c functions. If I allocate a huge memory chunk in one c function, will this memory be released after the c function return to go code? I plan to use this memory in another c function, and free the memory in a third c function.

Thanks.
Cheers,
Eric

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

Gmane