Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-15 Thread andrey mirtchovski
the code below which gzips and attaches a file to an email io.Writer
has worked for me for close to 5 years. it's not idiomatic go code so
don't use it verbatim, only as an example.

the boundary is something random the client chooses. i use a sha256
baked into the client. the same for every attachment.

func attach(w io.Writer, file, boundary string) {
fmt.Fprintf(w, "\n--%s\n", boundary)
contents, err := os.Open(file)
if err != nil {
fmt.Fprintf(w, "Content-Type: text/plain; charset=utf-8\n")
fmt.Fprintf(w, "could not open file: %v\n", err)
} else {
defer contents.Close()
fmt.Fprintf(w, "Content-Type: application/octet-stream\n")
fmt.Fprintf(w, "Content-Transfer-Encoding: base64\n")
fmt.Fprintf(w, "Content-Disposition: attachment;
filename=\"%s\"\n\n", filepath.Base(file)+".gz")

b64 := base64.NewEncoder(base64.StdEncoding, w)
gzip := gzip.NewWriter(b64)
io.Copy(gzip, contents)
gzip.Close()
b64.Close()
}
fmt.Fprintf(w, "\n--%s\n", boundary)
}

On Sat, Jul 15, 2017 at 7:48 PM, jesse junsay  wrote:
> Hi,
>
> Been trying do email attachments in golang using net/smtp and mail packages
> but to no avail. I tried attaching email and extracting attachments from
> email using multipart but I just cant figure out how that works in golang. I
> have tried to look for samples online and even posting on golang forum and
> stackoverflow. It seems like no one has ever done this issue before. Any
> help will be greatly appreciated.
>
>
> --
> 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] Attaching to email and extracting email attachments

2017-07-15 Thread jesse junsay
Hi,

Been trying do email attachments in golang using net/smtp and mail packages 
but to no avail. I tried attaching email and extracting attachments from 
email using multipart but I just cant figure out how that works in golang. 
I have tried to look for samples online and even posting on golang forum 
and stackoverflow. It seems like no one has ever done this issue before. 
Any help will be greatly appreciated.


-- 
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] gitcreepy – get GitHub users' previous email addresses from all their historical commits!

2017-07-15 Thread nosequeldeebee
https://github.com/nosequeldeebee/gitcreepy

It's stunning how much personal information you can get from Github users 
through its developer APIs. In addition to profile information, a list of 
every email address they've used in historical public commits can be 
extracted. Many users sign up for Github with their personal email 
addresses and only obfuscate them after they've made public commits, which 
imprints them in the public record!

-- 
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] Web UI library in pure Go?

2017-07-15 Thread Wojciech S. Czarnecki
On Sat, 15 Jul 2017 09:30:39 -0700 (PDT)
Leff Ivanov  wrote:

> Is there something like Vaadin, GWT, ZK in Golang world? I mean something
> to do web UIs in pure Go without the need to write JavaScript and HTML.
> 

https://github.com/icza/gowut GPL3
https://github.com/gu-io/gu MIT

-- 
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] Customized Go template FuncMap example

2017-07-15 Thread Tong Sun
Thanks.

I don't know what kind of goals you are trying to achieve, but here are
mine:

What I'm trying to do is to modulelize customized Go template functions,
say one module provide advanced regexp support, while another one
specialized in text formatting (vertical aligning, text folding in column,
etc), so on and so forth, *each of the module has a collection of their
own customized template functions*.

The goal is to define such modules separately, as a building block, provide
them as libraries, and the end user can pick and choose what what, and
chain the customized template functions together using a series of `.Funcs`
calls.

Thus, I was trying to wrap the myFuncMap into a callable function, so
that the library works for both text and html templates.

So how is the following fitting into the above goals? Thx.

On Sat, Jul 15, 2017 at 12:51 PM, Matt Ho  wrote:

> Given that text and html templates are separate calls anyways, why not
> just make separate calls for your custom funcmap?  For example:
>
> package template
>
> import (
>   html "html/template"
>   text "text/template"
> )
>
> func Html(name string, fm html.FuncMap) *html.Template {
>   return html.New(name).Funcs(fm)
> }
>
> func Text(name string, fm text.FuncMap) *text.Template {
>   return text.New(name).Funcs(fm)
> }
>
>

-- 
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] json.Unmarshal and numbers: go 1.7 vs go 1.8

2017-07-15 Thread Ian Lance Taylor
On Sat, Jul 15, 2017 at 11:20 AM, Traun Leyden  wrote:
>
> On go 1.7, I'm seeing a difference in behavior between json.Unmarshal and
> json.Decoder when it comes to json numbers.
>
> This test program which compares json.Unmarshal() vs. json.NewDecoder()
> behavior w.r.t to numbers works fine on go 1.8, but if I run it against go
> 1.7 on OSX I get this error:
>
> $ go run main.go
> 2017/07/15 11:19:15 json.Unmarshal() + json.Marshal(): {
> "Doc": {
> "GithubUsers": [
> {
> "id": 3.411441e+06,
> "type": "User"
> }
> ],
> "_id": "github_users_default"
> }
> }
> 2017/07/15 11:19:15 The id field was changed to floating point format
> 2017/07/15 11:19:15 Couldn't unmarshal into github user object: json: cannot
> unmarshal number 3.411441e+06 into Go value of type int
> 2017/07/15 11:19:15 json.Decode() + json.Marshal(): {
> "Doc": {
> "GithubUsers": [
> {
> "id": 3411441,
> "type": "User"
> }
> ],
> "_id": "github_users_default"
> }
> }
>
>
> I'm going to update to Go 1.8 and forget about it, but out of curiosity does
> anyone know if it was intentional change in Go 1.8?

Yes.  Look for encoding/json under
https://golang.org/doc/go1.8#minor_library_changes .

"Marshal encodes floating-point numbers using the same format as in
ES6, preferring decimal (not exponential) notation for a wider range
of values. In particular, all floating-point integers up to 264 format
the same as the equivalent int64 representation."

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] json.Unmarshal and numbers: go 1.7 vs go 1.8

2017-07-15 Thread Traun Leyden

On go 1.7, I'm seeing a difference in behavior between json.Unmarshal and 
json.Decoder when it comes to json numbers.

This test program  which compares 
json.Unmarshal() vs. json.NewDecoder() behavior w.r.t to numbers works fine 
on go 1.8, but if I run it against go 1.7 on OSX I get this error:

$ go run main.go
2017/07/15 11:19:15 json.Unmarshal() + json.Marshal(): {
"Doc": {
"GithubUsers": [
{
"id": 3.411441e+06,
"type": "User"
}
],
"_id": "github_users_default"
}
}
2017/07/15 11:19:15 The id field was changed to floating point format
2017/07/15 11:19:15 Couldn't unmarshal into github user object: json: 
cannot unmarshal number 3.411441e+06 into Go value of type int
2017/07/15 11:19:15 json.Decode() + json.Marshal(): {
"Doc": {
"GithubUsers": [
{
"id": 3411441,
"type": "User"
}
],
"_id": "github_users_default"
}
}


I'm going to update to Go 1.8 and forget about it, but out of curiosity 
does anyone know if it was intentional change in Go 1.8?

-- 
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] Customized Go template FuncMap example

2017-07-15 Thread Matt Ho
Given that text and html templates are separate calls anyways, why not just 
make separate calls for your custom funcmap?  For example:

package template

import (
  html "html/template"
  text "text/template"
)

func Html(name string, fm html.FuncMap) *html.Template {
  return html.New(name).Funcs(fm)
}

func Text(name string, fm text.FuncMap) *text.Template {
  return text.New(name).Funcs(fm)
}

-- 
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] Web UI library in pure Go?

2017-07-15 Thread Leff Ivanov
Is there something like Vaadin, GWT, ZK in Golang world? I mean something to do 
web UIs in pure Go without the need to write JavaScript and HTML.

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