edward.whitman80 | 29 Sep 14:58 2014
Picon

Deadlock with HTTP client

I'm running into a issue when running high concurrency using net/http.

I'm getting deadlocks, using strace the program invariably blocks on:

futex(0x1282e38, FUTEX_WAIT, 0, NULL...

Essentially I'm getting social metrics for a bunch of domains, there are multiple stages of firing up goroutines. I run with a throttle, and by testing via runtime.NumCPU() all the way upto 128 concurrent workers - all levels of concurrency end in the FUTEX_WAIT

Each worker get's social data for the domain, e.g.:

// Facebook
wg.Add(1)

go func() {
defer wg.Done()

s.FacebookShares, s.FacebookComments = getFacebook(d)
}()

...

Individual logic:

type facebook struct {
Shares   uint64 `json:"shares,omitempty"`
Comments uint64 `json:"comments,omitempty"`
}

const facebookURL = "https://graph.facebook.com/"

func getFacebook(d string) (s, c uint64) {
var wg sync.WaitGroup

for _, url := range []string{"http://" + d, "https://" + d} {
wg.Add(1)

go func(url string) {
defer wg.Done()

b, err := getBody(facebookURL + url)

if err != nil {
return
}

var fb facebook

if err = json.Unmarshal(b, &fb); err != nil {
return
}

atomic.AddUint64(&s, fb.Shares)
atomic.AddUint64(&c, fb.Comments)
}(url)
}

wg.Wait()

return
}

I'm using a global HTTP client:

HTTP = &http.Client{
Timeout: 5 * time.Second,
/*Transport: &http.Transport{
Dial: func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, dialTimeout)
},
},*/
}

(I've tried several examples online, SetDeadline() etc to no avail.)

And fetching []byte content via:

func getBody(url string) ([]byte, error) {
r, err := HTTP.Get(url)

if err != nil {
return nil, err
}

defer r.Body.Close()

if r.StatusCode != http.StatusOK {
return nil, errRequest
}

return ioutil.ReadAll(r.Body)
}

I'm using a tip build on 64 bit Linux, this behaviour is exhibited on my desktop install and a deployment server.

Has anyone come across these issues using high concurrency + net/http requests, or am I doing something obviously stupid?

--
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.
Chris Hines | 29 Sep 07:45 2014

Inconsistent handling of %+v and %#v when printing composite types.

I am writing a type that implements the fmt.Formatter interface and I have come across a curious inconsistency in the way that package fmt treats the '+' and '#' flags for the %v verb.

The issue is that when printing a composite type containing values that implement fmt.Formatter, the type's Format(f fmt.State, c rune) is called in a way that formats such as "%+v" and "%#v" appear to it as only "%v". Here is a copy of the TestFlagParser code from the standard library that I have modified to demonstrate the issue for arrays: http://play.golang.org/p/mtWFU1M8-G

It is not clear to me whether this is the intended behavior of package fmt. I don't see any tests exercising this combination of features and the documentation seems ambiguous on this particular usage. I have copied the relevant portion of the docs below for reference. The section after "[snip]" seems to only give special exemptions to %T and %p from the rules that follow. Thus, it would seem when printing a composite structure that did not itself implement fmt.Formatter, but contained values that did, that a "%+v" or a "%#v" format should apply to each contained value just as a "%+q" or a "%#x" does.

Note that when printing individual values the '+' and '#' flags *are* discoverable, it is only when the value is reached indirectly through a composite value that the '+' and '#' flags are not passed on (and only for the 'v' verb).

Am I missing something or is this a bug. If it is a bug, is it an implementation or documentation bug?

General:

%v the value in a default format. when printing structs, the plus flag (%+v) adds field names %#v a Go-syntax representation of the value

[snip]

Except when printed using the verbs %T and %p, special formatting considerations apply for operands that implement certain interfaces. In order of application:

1. If an operand implements the Formatter interface, it will be invoked. Formatter provides fine control of formatting.

2. If the %v verb is used with the # flag (%#v) and the operand implements the GoStringer interface, that will be invoked.

If the format (which is implicitly %v for Println etc.) is valid for a string (%s %q %v %x %X), the following two rules apply:

3. If an operand implements the error interface, the Error method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any).

4. If an operand implements method String() string, that method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any).

For compound operands such as slices and structs, the format applies to the elements of each operand, recursively, not to the operand as a whole. Thus %q will quote each element of a slice of strings, and %6.2f will control formatting for each element of a floating-point array.

--
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.
小菜 | 29 Sep 05:59 2014
Picon

[go-nuts] http.Serve ReadTimeout,WriteTimeout and keep-alive ?

What is the golang http.Server default timeout?

ReadTimeout and WriteTimeout these two parameters whether they play a role, and what is the relationship between “keep-alive, keep-alive to the two parameters that influence?



package main


import (

        "flag"

        "fmt"

        "net/http"

        "time"

)


var r *int = flag.Int("r", 0, "read timeout")

var w *int = flag.Int("w", 0, "write timeout")


func main() {

        flag.Parse()

        http.HandleFunc("/", slashHandler)

        server := http.Server{

                Addr:         ":8123",

                //ReadTimeout:  time.Duration(*r) * time.Second,

                WriteTimeout: time.Duration(*w) * time.Second,

        }

        fmt.Printf("Read timeout: %ds, write timeout: %ds\n", *r, *w)

        server.ListenAndServe()

}


func slashHandler(w http.ResponseWriter, r *http.Request) {

        time.Sleep(200 * time.Second)

        w.Write([]byte("Hello world!\n"))

}


WriteTimeout does not work!

--
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.
Matt Ho | 29 Sep 03:57 2014
Picon

[ANN] httpctx - json http client that utilizes google's context package

httpctx is an http client library intended for working with json apis using google's context package.  

Key Features:
  • Enables coordination with multiple go-routines through cancelation, deadlines, and timeouts via google context (http://code.google.com/p/go.net/context)
  • Simplifies interacting with json request/response apis
  • Supports user defined authentication
https://github.com/savaki/httpctx

Any comments or suggestions would be appreciated.

M

--
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.
John Souvestre | 29 Sep 03:42 2014

Return Values

Hi.

I see that in some cases the latter of two return values can be ignored.
Examples:
    for i := range []int{1,2,3} { ... }
vs
    for i, x := range []int{1,2,3} { ... }
And
    x := <-ch
vs
    x, ok := <-ch

Are there other cases where this is so?

Is this something which I can implement when defining a function?  How?

Is there such a thing as a function with a variadic return value?

Thanks,

John

    John Souvestre - New Orleans LA

--

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

Picon

Order and safety on boolean operations on if statements

 Can I have something like this:
 if exp1 || exp2 { 
  something()
 }
 where evaluating exp2 is unsafe if exp1 is true? The same doubt applies to the && operator:
 if exp1 && exp2 { 
  something()
 }

In other words, can I assume that, in the first scenario, if exp1 is true exp2 won't be evaluated?
 

--
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.
Mehrzad Irani | 28 Sep 22:35 2014
Picon

Can the Named Return value having same variable name as function argument

Hi Guys,

I'm new to go, and have a question from the golang tour that I've been trying w.r.t functions returning named results. Is it possible for a result variable to have the "SAME" name as the function argument??

Like for eg. can the below function statement be correct

func calc_sqrt(num, mysqrt float64) (mysqrt float64, iter int) {
...
}


I get the the understand that I will get a duplicate argument error:
./sqrt_newt.go:22: duplicate argument mysqrt

However, how can this be achieved, if I do not want to declare another variable for holding the mysqrt value?

--
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.
Luis Furquim | 28 Sep 20:15 2014
Picon

TLS client authentication

Hello,

I am trying to write a server in Go that accepts connections from clients
authenticated by a certificate issued by my self signed CA.

I generated the keys/certificates as follows:

1) CA
openssl genrsa -des3 -passout pass:qwerty -out  private/rootCA.key 2048
openssl rsa -passin pass:qwerty -in private/rootCA.key -out private/rootCA.key
openssl req -config openssl.cnf -new -x509 -subj '/C=BR/ST=RS/L=POA/O=MyOrg CA/CN=myserver.example.com' -days 999 -key private/rootCA.key -out certs/rootCA.crt

2) Server
openssl genrsa -des3 -passout pass:qwerty -out private/server.key 2048
openssl rsa -passin pass:qwerty -in private/server.key -out private/server.key
openssl req -config openssl.cnf -new -subj '/C=BR/ST=RS/L=POA/O=MyOrg/CN=myserver.example.com' -key private/server.key -out csr/server.csr
openssl ca -batch -config openssl.cnf -days 999 -in csr/server.csr -out certs/server.crt -keyfile private/rootCA.key -cert certs/rootCA.crt -policy policy_anything

3) Client
openssl genrsa -des3 -passout pass:qwerty -out private/client.key 2048
openssl rsa -passin pass:qwerty -in private/client.key -out private/client.key
openssl req -config openssl.cnf -new -subj '/C=BR/ST=RS/L=POA/O=MyOrg/CN=John Doe' -key private/client.key -out csr/client.csr
openssl ca -batch -config openssl.cnf -days 999 -in csr/client.csr -out certs/client.crt -keyfile private/rootCA.key -cert certs/rootCA.crt -policy policy_anything

3.1) To import and test in Firefox I tried both:
openssl pkcs12 -export -out certs/client.pfx -inkey private/client.key -in certs/client.crt -certfile certs/rootCA.crt
openssl pkcs12 -export -out certs/client.pfx -inkey private/client.key -in certs/client.crt -certfile certs/rootCA.crt -certfile certs/server.crt


I had success with my first test with openssl:
openssl s_server -accept 5640 -cert certs/server.crt -key private/server.key  -CAfile certs/client.crt -tls1
openssl s_client -connect localhost:5640 -cert certs/client.crt -key private/client.key -CAfile certs/rootCA.crt -tls1

So, I wrote my test server in Go and failed trying a connection with wget:
wget --private-key=private/client.key --certificate=certs/client.crt --no-check-certificate https://myserver:9001/sync/acd
Resolvendo myserver.example.com (myserver.example.com)... 192.168.3.6
Conectando-se a myserver.example.com (myserver.example.com)|192.168.3.6|:9001... conectado.
OpenSSL: error:14094412:SSL routines:SSL3_READ_BYTES:sslv3 alert bad certificate

Then I tested and failed with Firefox using both certificates generated in 3.1 with the message
O sistema remoto SSL não pôde comprovar a homologação do seu certificado. (Código do erro: ssl_error_bad_cert_alert) 
In Google translator english it  is "SSL peer was unable to confirm the approval of your certificate".

The pieces of the code on the test server:

func init() {
   caCert, _       = ioutil.ReadFile("certs/rootCA.crt")
   serverCert, _   = ioutil.ReadFile("certs/server.crt")

   block, _ := pem.Decode(caCert)
   cert, err := x509.ParseCertificate(block.Bytes)

   if err != nil {
      fmt.Println(err)
   }

   certPool = x509.NewCertPool()
   certPool.AddCert(cert)
}


func (server *Server) ListenAndServeTLS(addr string, cert, key string) error {
   http.Handle("/", server)

   srv := &http.Server{
      Addr: addr,
      TLSConfig: &tls.Config{
         ClientAuth: tls.RequireAndVerifyClientCert,
         ClientCAs: certPool,
      },
   }

   srv.TLSConfig.BuildNameToCertificate()

   return srv.ListenAndServeTLS(cert, key)

}

func main() {
.
.
.
   err := srv.ListenAndServeTLS(":9001", "certs/server.crt", "private/server.key")
   if err != nil {
      fmt.Println(err)
   }

}



Any suggestions?

Thank you!


--
Luis Otavio de Colla Furquim

--
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.
Михаил Вицен | 28 Sep 20:01 2014
Picon

what is best practice of using multiple channels for answers of message server?

Hello everyone!

I'm writing messages server in go and can't recognize best way to send response messages to clients.
Server is goroutine, which listens single channel of messages. Messages are received by multiple connection pool (some of them receive protobuf encoded messages over tcp socket, some - json encoded messages over web socket; clients over different connections are equivalent). After processing message i have to write an asnwer. I know 2 variants:
1) i can store multiple chanels for different connection pool and store a map, which holds match clientId => chan. in this case i have to listen for one more channel to receive new output channels and have to store the map with matches.
2) i can pass chan for response in message. but in some situations i have to send information not only for sender of message, but also to another connections. so 

Maybe there is a "ussual" way for this problem?

--
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.
Jim Spring | 28 Sep 17:06 2014
Picon

golang-nuts@... - 25 updates in 12 topics

Were

On Sep 28, 2014 4:21 PM, <golang-nuts-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:
Ignacio Grande <ncc1701zzz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 07:08AM -0700

I found this two and a half years old topic about refreshing godoc. It
seems that the sync_minutes options has been removed.
 
I'm working with several open files, from libraries and programs, and I
would like to use godoc to check the function names and parameters as I
write.
 
Is there an alternative to restarting godoc? A "refresh" button would be
nice...
 
Thanks.
 
 
On Sunday, February 12, 2012 9:50:15 PM UTC+1, Kyle Lemons wrote:
"Lars Pensjö" <lars.pensjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 04:49AM -0700

I add "add-auto-load-safe-path
/usr/share/go/src/pkg/runtime/runtime-gdb.py" to .gdbinit, and then start
gdb. Now I get:
 
*$ go version*
go version go1.2.1 linux/amd64
*$ gdb MergePrograms.test *
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from MergePrograms.test...done.
File "/usr/share/go/src/pkg/runtime/runtime-gdb.py", line 358
print s, ptr['goid'], "%8s" % sts[long((ptr['status']))], blk.function
^
SyntaxError: invalid syntax
*(gdb) *
 
 
 
What is wrong?
Harmen B <harmen-dUiv306/KX5AJNB5q9IVfA@public.gmane.org>: Sep 28 04:02PM +0200

In python3 `print` has changed from a keyword to a function (so it needs
parenthesis). My guess is you have python3 as the `python` command, but it
should be python 2.7.
 
Hiroshi Sakurai <an.olive.tree-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 10:54PM +0900

> You are writing Go, not Java. Why are you trying to implement a Java
> interface?
 
It's just a technical question. My intention was not mimicking Java interface.
 
> Fine, but don't make it your basic interface. Make read-with-timeout
> a higher level function.
 
I now understand what you said. I was planning to provide those two
functions at the same level API.
- Read()
- ReadWithTimeout()
 
As you said, it's better to make ReadWithTimeout a higher level API.
Thank you for the advice.
 
> return nil, errors.New("timed out")
> }
> }
 
When implementing this readWithTimeout() function, my original
question comes again.
 
I want this function to poll the channel when timeout == 0.
How should I change the code?
 
 
> level functions. Don't push complexities like timeouts into the
> lower-level interface. In Go, the appropriate lower-level interface
> is a blocking interface.
 
I see. Thank you for the detailed explanation
 
 
> arrive before the duration expires, and you go back and ask for
> another five bytes, does the full duration still apply, or should it
> be adjusted for the time already spent reading?
 
I see. In my case, it's not stream oriented but packet oriented like
UDP. There's not this ambiguity in this case.
There still is another ambiguity of "when the starting point is" when
using a duration as a timeout but I don't think it's a big problem.
 
--
Hiroshi
 
 
On Sun, Sep 28, 2014 at 2:44 AM, Ian Lance Taylor <iant-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:
MarkH <markshathaway-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 08:37PM -0700

I hadn't given thought to putting a function in a struct, but it would seem
awfully usefull for implementing some kind of genericity by hand. But, of
course, the idea of putting functions in an interface is even better (at
least in general). Perhaps someone could think of a narrow specific reason
for doing it with structs, but it wouldn't be the ideal general approach.
 
 
On Saturday, September 27, 2014 9:53:04 AM UTC-4, Tad Vizbaras wrote:
 
Jesse McNelis <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org>: Sep 28 01:50PM +1000

> This compiles but I wonder what would I use it for? Any examples in standard
> library that would use this?
 
http.Client has a CheckRedirect field that you can assign a function
to that will be used to decide whether or not the client should follow
a certain redirect.
http://golang.org/pkg/net/http/#Client
 
http.Server has a ConnState field that you can assign a function to
that will be called when the state of a connection changes.
http://golang.org/pkg/net/http/#Server
 
http.Transport has a Proxy and a Dial field for similar purposes.
http://golang.org/pkg/net/http/#Server
David DENG <daviddengcn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 12:32AM -0700

You can consider this as another form of interface.
 
On Saturday, September 27, 2014 6:53:04 AM UTC-7, Tad Vizbaras wrote:
Tahir <welcometothebasement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 05:31AM -0700

You can use it to decorate a random function given a certain context.
 
On Saturday, September 27, 2014 2:53:04 PM UTC+1, Tad Vizbaras wrote:
Nick Craig-Wood <nick-CpW1AI6bxKPNo8nFJ24aGw@public.gmane.org>: Sep 28 02:14PM +0100

On 28/09/14 04:50, Jesse McNelis wrote:
> http://golang.org/pkg/net/http/#Server
 
> http.Transport has a Proxy and a Dial field for similar purposes.
> http://golang.org/pkg/net/http/#Server
 
sync.Pool has a New function for the user to fill in
 
http://golang.org/pkg/sync/#Pool
 
type Pool struct {
 
// New optionally specifies a function to generate
// a value when Get would otherwise return nil.
// It may not be changed concurrently with calls to Get.
New func() interface{}
// contains filtered or unexported fields
}
 
--
Nick Craig-Wood <nick-CpW1AI6bxKPNo8nFJ24aGw@public.gmane.org> -- http://www.craig-wood.com/nick
Shuhei Tanuma <chobieee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 03:28AM -0700

Hi, I'm writing MQTT server with go.
 
MQTT has Session feature that is able to detach, attach existing
connection. Currently, I use sync.Mutex to swap existing connection and
dummy connection.
Although, I'd like to swap struct member which type is interface.
As I guess atomic.SwapPointer has several advantages over mutex.Lock (no
need to lock every time...)
 
I simplified my problem on Go Playground: I could do with specific type (A)
http://play.golang.org/p/oerL4ldtnl
Although, I'm not sure how do I operate with interface like this (B)
http://play.golang.org/p/Fg9Qu0K4d_
 
type Quacker interface {
Quack()
}
 
type Toy struct {
c Quacker // how to do atomic.SwapPointer?
}
 
I guess interface is not simple pointer like *TinyDuck so I can't swap with
(A) idioms. How do I write this?
 
Thanks,
Shuhei
Tahir <welcometothebasement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 06:03AM -0700

Interesting.
I think it is because an interface is a Dword.
Also, I've been wondering shouldn't you use `Compare and Swap` rather to
implement lock-freedom in this case?
(I don't have a response unfortunately :(
 
 
On Sunday, September 28, 2014 11:28:02 AM UTC+1, Shuhei Tanuma wrote:
bsr <bsr203-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 06:36PM -0700

Hello,
 
What is the best way to gofmt a program which is read from stdin. I am not
too familiar with piping, but this almost work
 
 
echo "package foo; type T struct {
 
Var1 type1 `json:"var,omitempty"` // somecomment1
 
}" | gofmt
 
 
this outputs
 
-bash: json:var,omitempty: command not found
 
package foo
 
 
type T struct {
 
Var1 type1 // somecomment1
 
}
 
how can I make it to use field tag? or is there a better way than echoing
the string.
 
For the context, I am calling this through node.js
 
function format(src) {
var cmd = 'echo "' + src + '" | gofmt'
child_process.exec(cmd, function (err, stdout, stderr) {
....
});
}
 
where src is the program.
"Wael M. Nasreddine" <wael.nasreddine-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 06:46PM -0700


> echo "package foo; type T struct {
 
> Var1 type1 `json:"var,omitempty"` // somecomment1
 
> }" | gofmt
 
The backtick in here (the one right before the word json) is being
evaluated as a subshell, so you need to wrap everything in a single quote
rather than a double quote, which also means you need to escape inner
double quotes with a backslash.
 
 
 
--
Wael Nasreddine | SRE at Google | wael.nasreddine-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org | (650) 735-1773
bsr <bsr203-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 07:02PM -0700

thank you. it worked, I only changed this line
 
var cmd = "echo '" + d + "' | gofmt";
 
I didn't have to escape the double quotes (if I do, the backslash is in the
output).
 
thanks again for your help.
 
hope echoing like this is still the best way to read from stdin.
 
On Saturday, September 27, 2014 9:47:26 PM UTC-4, Wael Nasreddine wrote:
luzon83 <at> gmail.com: Sep 28 01:50AM -0700

On Sunday, September 28, 2014 4:02:18 AM UTC+2, bsr wrote:
 
> hope echoing like this is still the best way to read from stdin.
 
No, it's not the best way to write to stdin from Node.js. Try this:
 
var exec = require('child_process').exec;
 
var src = 'package main\nimport "fmt"\nfunc main() {\nfmt.Println("hello,
world")\n}';
 
var gofmt = exec('gofmt', function (err, stdout, stderr) {
console.log(stdout);
});
gofmt.stdin.setEncoding = 'utf-8';
gofmt.stdin.write(src);
gofmt.stdin.end();
bsr <bsr203-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 05:24AM -0700

looks much better .. thank you.
 
On a side note, it works, but "setEncoding" is for readable stream
(process.stdin). but as per the manual, child_process.stdin, writable
stream, don't have it.
http://nodejs.org/api/stream.html
 
thanks again for your help.
 
 
orhiltch <at> gmail.com: Sep 27 10:30PM -0700

Thanks for the tip David.
 
Unforunately adding the -d flag did not solve the issue:
 
 
16.97s$ ./go_appengine/goapp get -d
 
package code.google.com/p/goauth2/appengine/serviceaccount
 
imports code.google.com/p/goauth2/appengine/serviceaccount
 
imports code.google.com/p/goauth2/appengine/serviceaccount: no buildable Go source files in /home/travis/gopath/src/code.google.com/p/goauth2/appengine/serviceaccount
 
The command "./go_appengine/goapp get -d" failed and exited with 1 during .
 
 
I ended up writing the goapp get command as a shell script that always
returns 0 for now. So in my .tavis file I have:
before_script: ./script/ci/get_deps.sh
and in the get_deps.sh I've got:
 
#!/bin/sh
echo "running goapp get to fetch dependencies..."
./go_appengine/goapp get
echo "dependencies fetched."
exit 0
 
This works as a workaround (because even though the script always returns
0, if the dep failed to be fetched, then the compilation would fail in the
next step, so not a very silent failure) but obviously not ideal.
 
On Sunday, September 28, 2014 12:08:21 AM UTC+3, David Symonds wrote:
Sebastien Douche <sdouche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 28 04:12AM +0200

> I thought this was kinda neat, so I wanted to share.
 
> It runs in your browser. Whenever you type something, it immediately parses the AST and prints it back. So you can see how formatting works at every keystroke.
 
Hi Dmitri,
is your project? Waht is the goal?
 
 
--
Sebastien Douche <sdouche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Twitter: <at> sdouche / G+: +sdouche
Dmitri Shuralyov <shurcool-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 08:03PM -0700

Yes, it's my project.
 
2 reasons:
 
1. (Assuming you're a touch typist) Seeing how a system reacts to your
input in a live manner can be pretty eye opening about how it works, thanks
to the tight feedback loop. I thought it was interesting to enter some Go
code and watch how it gets formatted on the right hand side as you type. It
shows you the kind of formatting flexibility that is supported. Most people
only run gofmt on save, or manually, so you don't quite see how it reacts
when you're halfway finished typing code. This lets you see that.
 
2. I thought it was interesting that we can build something like this that
runs in the browser so easily now. It took me half an hour to go from idea
in my head to having it working. Without GopherJS, something like this
would take weeks to implement by hand in JavaScript, and it just wouldn't
be feasible.
 
So I wanted to share it and see what people thought... It shows something
unusual that can be done with Go, and might inspire people to do more
out-of-the-box thinking.
 
I made another of these today, "Live markdownfmt", which you can try here:
 
https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/live-markdownfmt/live-markdownfmt.html
 
I found it was a good way for me to test my code when I was working to fix
an issue in it. I could make code changes, refresh the browser and see how
the new code works.
 
 
On Saturday, September 27, 2014 7:13:12 PM UTC-7, Sébastien Douche wrote:
Camilo Aguilar <camilo.aguilar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 09:58PM -0500

Nice tip! FWIW, you can also use http://direnv.net/ for a similar purpose.
 
On Thu, Sep 25, 2014 at 8:06 PM, meta keule <marcrenearns-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:
 
 
--
*Camilo Aguilar*
Software Engineer
http://github.com/c4milo
Camilo Aguilar <camilo.aguilar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 07:43PM -0500

camilo <at> grinch-2 ~/Development/go % hg identify
1a58c0ea234f (release-branch.go1.3)
 
 
--
*Camilo Aguilar*
Software Engineer
http://github.com/c4milo
Jason Phillips <jasonryanphillips-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 07:19PM -0700

Same test failure (and results) on Windows 8.1 x64.
 
gcc 4.7.2
 
John Sphar <jlsphar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 05:46PM -0700

Feel free to let me know if you're interested. I've been told by the house
it's easy to switch the names.
 
- John
Tahir <welcometothebasement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 06:27PM -0700

Why is it more expensive if you pay in euro ?
 
On Sunday, September 28, 2014 1:46:48 AM UTC+1, John Sphar wrote:
akwillis <akwillis1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Sep 27 05:03PM -0700

nice work. I'd like customizable fonts(size, color, type), customizable
colors for text highlighting and background. I'd prefer the menu to be
horizontal and aligned left.
 
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

--
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.
Lars Pensjö | 28 Sep 13:49 2014
Picon

gdb and runtime-gdb.py syntax error

I add "add-auto-load-safe-path /usr/share/go/src/pkg/runtime/runtime-gdb.py" to .gdbinit, and then start gdb. Now I get:

$ go version
go version go1.2.1 linux/amd64
$ gdb MergePrograms.test 
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from MergePrograms.test...done.
  File "/usr/share/go/src/pkg/runtime/runtime-gdb.py", line 358
    print s, ptr['goid'], "%8s" % sts[long((ptr['status']))], blk.function
          ^
SyntaxError: invalid syntax
(gdb) 


What is wrong?

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