cyt046 | 18 Dec 00:59 2014
Picon

Microdata Parser using xpath (gokogiri)

Hi all,
I wrote an microdata parser using gokogiri. The code is hosted in github (https://github.com/dsrcl/microdata-parser) with documentation on README.

--
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.
Greg Ingelmo | 18 Dec 05:32 2014
Picon

Teapot

Was perusing http constants and stumbled across http.StatusTeapot. Best contribution of all time!

https://github.com/golang/go/blob/master/src/net/http/status.go#L46

418 I'm a teapot (RFC 2324)This code was defined in 1998 as one of the traditional IETF April Fools' jokes, and is not expected to be implemented by actual HTTP servers.

--
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.
小菜 | 18 Dec 04:57 2014
Picon

How to let the specified tasks running on the specified goroutine

How to let the specified tasks running on the specified goroutine, and get goroutine id?

--
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.
小菜 | 18 Dec 02:34 2014
Picon

Golang supports native thread and multi process?

Golang supports native thread and multi process?
If I don't want to use goroutine.

--
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.
ajames | 17 Dec 22:21 2014

A shared folders and compiling for different platforms

I'm in early days developing with Go. My setup: I write code on OSX and keep a development VM in Vagrant. I've always used the shared folders feature in Vagrant to keep the code synced between host and guest.

The problem comes if I try to compile on either machine: It copies over the compiled file that is in the shared folder, and the other machine can't execute that binary because it's a different architecture. Compile in one, it overwrites the binary in the other.

Any insights on how to handle this? As far as I know NFS doesn't allow for excluding files -- it syncs everything.

Thanks.

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

Go

If the thought of building highly scalable systems in golang excites you, please check out Igneous Systems (http://www.igneous.io/).  We are an exciting new startup in Seattle with solid funding and extremely smart and motivated people.  I have been working there for about 4 months and having a blast!  Feel free to reach out to me directly.

http://hire.jobvite.com/m?3JJOUgwV

Asif
asif-jkFrV5q6ysEWenYVfaLwtA@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.
Chenxiao Ma | 17 Dec 21:06 2014
Picon

json marshal unsupported type: chan string

Hi,

I tried to marshal a struct but got some errors.

var AllRules map[string]Rule = make(map[string]Rule)
...
myRule, _ := AllRules[strconv.Itoa(id)]
resp, err := json.Marshal(myRule)
fmt.Println(err)    //prints "json: unsupported type: chan string"

However, if I use an AllRules array like var AllRules []Rule the json encoder worked like a charm. So basically it's not a problem of struct design like bsr's issue in https://groups.google.com/forum/#!topic/golang-nuts/xuFAnKfGMLE

I think json.Marshal can encode any type of container according to http://golang.org/pkg/encoding/json/#Marshal

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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
skarflacka232 | 17 Dec 20:44 2014
Picon

Validating a files content-type, the problem is "(mismatched types []string and string)"

package main

import (
   
"fmt"
   
"net/http"
   
"log"
   
"io/ioutil"
)

var types = map[string]string {
   
"png": "image/png",
   
"jpeg": "image/jpeg",
}

// hello world, the web server
func server
(w http.ResponseWriter, req *http.Request) {


    file
, handler, err := req.FormFile("file")
   
if err != nil {
            fmt
.Println(err)
   
}


   
if handler.Header["Content-Type"] == types["jpeg"] {
        fmt
.Println("works")
   
} else {
        fmt
.Println("doesn't work")
   
}


    data
, err := ioutil.ReadAll(file)
   
if err != nil {
            fmt
.Println(err)
   
}


    err
= ioutil.WriteFile(handler.Filename, data, 0777)
   
if err != nil {
            fmt
.Println(err)
   
}


    fmt
.Println(handler.Header["Content-Type"])

}


func main
() {
    http
.HandleFunc("/upload", server)

    err
:= http.ListenAndServe(":8080", nil)
   
if err != nil {
        log
.Fatal("ListenAndServe: ", err)
   
}
}

I want to validate a files content-type before uploading it, like checking if it's a png or not. Maybe I should just use the DetectContentType function instead?

If I can make a string to []string then everything should be solved I guess.

--
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.
adonovan | 17 Dec 20:33 2014
Picon

proposal: support int(bool) conversions in Go.1.5

I propose the following modest language change for Go 1.5.  (This is issue #9367.)

An explicit conversion int(b) where b has a boolean type would become legal, and would yield 1 if b is true, 0 otherwise.  Similar conversions would be legal for all numeric types.

Rationale: currently this function cannot be computed in a single expression, despite it being often useful, hard to misuse, efficiently implemented by modern ALUs, present in nearly all other languages, and syntactically natural in Go.

While I appreciate the value of avoiding implicit int/bool conversions, forbidding explicit ones seems slightly obtuse, and as a result of its omission, one must write four extra lines of code:

 var i int
 if b { 
     i = 1
 }
 ... i ...

which the gc compiler does not optimize this into the obvious single instruction.

The reverse operation bool(i), is not essential since i != 0 has the same effect and can be used in an expression context, but could be added for symmetry.  (I have no strong opinion.)

Since we like evidence, I count 73 occurrences in $GOROOT of an 'if' statement whose body simply assigns 1 to a variable.

% grep -wr -A2 if.*{  $GOROOT/src | grep -A1 "= 1$" | grep '}$' | wc -l
73

--
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.
Peter Kleiweg | 17 Dec 20:19 2014
Picon
Picon

Getting godoc to work in Go 1.4

I have some problems with godoc with Go 1.4

~ godoc unicode/utf8
2014/12/17 20:17:32 /src/unicode/utf8/utf8.go:385:6: expected operand, found 'range' (and 3 more errors)

~ go get -v -u golang.org/x/tools/godoc
Fetching https://golang.org/x/tools/godoc?go-get=1
Parsing meta tags from https://golang.org/x/tools/godoc?go-get=1 (status code 200)
get "golang.org/x/tools/godoc": found meta tag main.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/godoc?go-get=1
get "golang.org/x/tools/godoc": verifying non-authoritative meta tag
Fetching https://golang.org/x/tools?go-get=1
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
package golang.org/x/tools/godoc: /home/peter/go/src/golang.org/x/tools is from https://code.google.com/p/go.tools, should be from https://go.googlesource.com/tools

How do I solve this?

--
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.
ghthaker | 17 Dec 19:44 2014
Picon

lack of support for backreferences in GO's regular expressions

Since GO does not support backreferences in regexp support, what does one do in they wish to have a regular expression in which use of backrefrences is the natural way to go. Example, find and eliminated repeated words, something that I can do in PERL via:

$_="alpha:beta:beta:gamma:gamma:gamma:delta:eta:eta";
s/(\b[:\w]+\b)(?:\s*\1)+/$1/g;
print $_, "\n";              #  output is: alpha:beta:gamma:delta:eta

Are there no other unofficial packages for GO that support this capability? I have read various papers about how GO's regexp use more stable/predictable worst case run times, but lack of backreferences seem like a serious issue to me, coming from a Perl world as I do.

Gautam

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