This is a real world example from our middleware.
https://github.com/cybozu-go/cmd/blob/master/http.go#L122-L132
It uses the context in the request to propagate a unique ID.
Please see also my announcement of the package here :-)
https://groups.google.com/forum/#!topic/golang-nuts/I0wVToodcdo
201
Here is an example:
https://play.golang.org/p/3mFS_7-mM8
You have two wrapper handlers (logIt and authIt). authIt, authenticates
every handler you want to authenticate. For simplicity it takes a user id
from a url and checks roles.
logIt is another wrapper handler, that logs every handler and it
H
On Friday, September 2, 2016 at 12:39:16 PM UTC-7, kevin.nor...@gmail.com
wrote:
>
> If I understand correctly using Context will allow "middleware" to pass
> data into the handler? Can someone provide a simple example please.
>
>
>
>
--
You received this message because you are subscribed
Daniel, fwiw I couldn't get govendor list to work in my environment.
Sam, thanks a lot of that snippet. I also had some trouble running that,
but I was able to reverse engineer the important parts out to generate a
one-liner that worked for me.
go list -f '{{ range .Imports }}{{printf "\t%q -> %
Francis,
And, of course,
keyVals := make([]string, b.N*10)
// ...
for _, key := range keyVals {
setTwo(s, key)
}
should be
keyVals := make([]string, b.N)
// ...
for _, key := range keyVals {
setTwo(s, key)
}
or
s /b.N*10/b.N/g
Peter
On Fri, Sep 2, 2016 at 4:38 PM, peterGo w
In your original example, if you don't cast, it works.
https://play.golang.org/p/g-GScYkA5S
The explanation is here:
https://groups.google.com/forum/#!topic/golang-nuts/x3nOMDCLv5M
Le vendredi 26 août 2016 17:45:40 UTC+2, T L a écrit :
>
>
>
> package main
>
> type Age int
>
> func main() {
>
Francis,
First, fix any bugs.
For example, "The benchmark function must run the target code b.N times."
https://golang.org/pkg/testing/
Therefore,
keyVals := make([]string, b.N*10)
// ...
for _, key := range keyVals {
setOne(s, key)
}
should be
keyVals := make([]string, b.N)
// ...
If I understand correctly using Context will allow "middleware" to pass
data into the handler? Can someone provide a simple example please.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emai
On Fri, Sep 2, 2016 at 1:20 PM, Davis Ford wrote:
> Does anyone know of a tool that can analyze dependencies and print a graph,
> specifically as it relates to golang vendor'd libraries. I'm using 1.7 and
> most tools don't seem to be able to produce results on a project that is
> using vendor'd
You may be interested in github.com/kardianos/govendor
govendor list -v
On Friday, September 2, 2016 at 11:20:54 AM UTC-7, Davis Ford wrote:
>
> Hi,
>
> Does anyone know of a tool that can analyze dependencies and print a
> graph, specifically as it relates to golang vendor'd libraries. I'm usin
thanks a lot !! It is very much appreciated.
The for loop is *very* clever.
Le vendredi 2 septembre 2016 16:30:21 UTC+2, Alan Donovan a écrit :
>
> On 2 September 2016 at 06:21, mhhcbon
> > wrote:
>
>> I dig into the repo you mentioned, TBHonnest, im not that wise, and it
>> remains unclear.
>>
working examle:
https://play.golang.org/p/KLZdle7R47
On Friday, September 2, 2016 at 8:07:32 PM UTC+3, Ринат Галиев wrote:
>
> Я не могу заставить работать попеременно 2 gorutines:
> не использовать новый imports
> использовать каналы
> получить результаты: 1 2 3 4 5 6
> согte after "// Красноломк
Hi,
Does anyone know of a tool that can analyze dependencies and print a graph,
specifically as it relates to golang vendor'd libraries. I'm using 1.7 and
most tools don't seem to be able to produce results on a project that is
using vendor'd dependencies.
Tools I've tried:
- https://git
On Friday, September 2, 2016 at 8:07:32 PM UTC+3, Ринат Галиев wrote:
>
> Я не могу заставить работать попеременно 2 gorutines:
> не использовать новый imports
> использовать каналы
> получить результаты: 1 2 3 4 5 6
> согte after "// Красноломкий "
>
> Основной пакет
>
> // красноломкий
>
> имп
Hi,
I took the liberty of creating what I think you're trying to achieve in the
go playground so I could test: https://play.golang.org/p/IgtSUNLakJ
Are you expecting the output of the two goroutines to be run in parallel so
you get the output 1 2 3 4 5 6?
Cheers
On Friday, September 2, 2016 a
Я не могу заставить работать попеременно 2 gorutines:
не использовать новый imports
использовать каналы
получить результаты: 1 2 3 4 5 6
согte after "// Красноломкий "
Основной пакет
// красноломкий
импорт "Время"
FUNC главный () {
идти FUNC () {
для _, значение: = диапазон [] INT {1, 3,
I looked at the C version, and it looks like it actually uses the TCL
regex library that has some slightly different characteristics than the
PCRE library.
On Thursday, September 1, 2016 at 4:34:41 PM UTC-4, DrGo wrote:
>
> What is the reason for Go particularly poor performance in regexdna as
On Friday, 2 September 2016 09:51:52 UTC-4, Kevin Conway wrote:
>
> Given a type T that implements interfaces A1 and A2, T is an acceptable
> input for any function that requires an A1 or A2 as input. Given A1 and A2
> are identical in definition, the return value of a function that returns an
>
I don't know the answer but if I were you, I would start from looking at
Windows applications written in Go and see how they have done.
For instance, the package https://github.com/lxn/walk has implemented lots
of Windows GUI stuff. It would probably provide the information you are
looking for.
On 2 September 2016 at 06:21, mhhcbon wrote:
> I dig into the repo you mentioned, TBHonnest, im not that wise, and it
> remains unclear.
> For the few i know, select is the approach to take, but the API is unclear.
>
> Not sure if it s possible to come up with something as straight as
> `NewReade
Not sure exactly how to describe this issue or the right words to use when
talking about some of the concepts. Here's a best effort.
Given a type T that implements interfaces A1 and A2, T is an acceptable
input for any function that requires an A1 or A2 as input. Given A1 and A2
are identical in d
You could close(done). It doesn't block, thus you won't have to allocate a
buffer.
chan struct{} would take even less space and WaitGroup seems unnecessary in
this code
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this g
Hi,
There are a lot of Go resources out there, but I've been missing a blog
aggregator for some time. So I built one :) It's now running on
http://planetgolang.com.
Planet Golang is statically generated by a Go program,
https://github.com/galdor/planetgolang.
I added a few feeds to start, but I'
Hi All,
I made a new library that I thought some people might find
useful: https://github.com/jlubawy/go-gcnl
Feedback and feature requests are gladly welcomed!
Thanks,
Josh
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from
Hi,
I'm one of the maintainers of Go Report Card http://goreportcard.com/ and I
am looking for advice on how to make it faster.
Basically we run a series of checks (gofmt, vet, etc.) on your Go
repository and provide a grade based on how many errors each check returns.
Each check runs in a sep
I have been working to reduce allocations in a local cache and found some
confusing behaviour around the allocs/op output when benchmarking.
A simplified reproducing version is pasted at bottom.
The behaviour is that setting a value in a single map yields 0 allocations,
setting a value in two m
Hello friends,
i am trying to write some win api in golang ,because these API not
implemented any PKG.
"syscall"
"github.com/contester/runlib/win32"
"golang.org/x/sys/windows"
API are code in C++
OpenDesktop
hdesk = OpenDesktop(
_T("default"), // the interacti
I prefer a GOPATH per project but never worry about setting it. I have a
small bash/dash script called gp which finds the GOPATH for me as long as
I'm in the project somewhere:
#!/bin/dash
paths=${PWD}
while [ "$paths" != "/" ]; do
if [ -d "$paths/bin" ]; then
if [ -d "$p
Pada Thu, 1 Sep 2016 21:10:44 +0200
Harald Weidner menulis:
> Hello,
>
> On Thu, Sep 01, 2016 at 01:59:12AM -0700, Muhammad Shulhan wrote:
>
> > > type Slices []string
> > >
> > > func (sl *Slices) String() string {
> > > return fmt.Sprint(sl)
> > > }
>
> > runtime: goroutine stack excee
I dig into the repo you mentioned, TBHonnest, im not that wise, and it
remains unclear.
For the few i know, select is the approach to take, but the API is unclear.
Not sure if it s possible to come up with something as straight as
`NewReader(os.Stdin).Block(false).Read()`
Le mercredi 31 août
`glide update` or a install should do the job, yes.
If that does not `mv vendor _vendor && glide install` to figure out if
things works or are stinky.
Do you mean you re in situation where you have one to many repo to update
by doing a fork / PR / merge
to actually make a significant change
Responses to a question like this tend to be either very detailed, or
vague. This one has all the gory details.
I develop under Linux. I'm happy to use fancy visual tools, but I also do
a lot of stuff from the command line.
I have a directory GOCODE where I put stuff that I fetch via go get.
Hi,
Test() never actually dereference the C string (now dangling) pointer after
C.free. And even if it did, it is unlikely that the C.free() resulted in
the memory page your string resided on was unmapped. Segfaults only happen
if you access unmapped memory.
- elias
On Friday, September 2, 2
Nevermind, looks like it is undefined behavior here.
On Friday, September 2, 2016 at 1:43:49 AM UTC-7, kane@sendgrid.com
wrote:
>
> Hello,
>
> I was expecting it to segfault after deallocating CString. How does it
> work internally?
>
> func (m *Message) Test() string {
> s := C.CString("tes
Hello,
I was expecting it to segfault after deallocating CString. How does it work
internally?
func (m *Message) Test() string {
s := C.CString("test")
C.free(unsafe.Pointer(s))
sh := reflect.StringHeader{(uintptr)(unsafe.Pointer(s)), 4}
return *(*string)(unsafe.Pointer(&sh))
}
--
You received
Hello Golang community,
I have released a new version of the GoBkm bookmark manager:
https://github.com/tbellembois/gobkm/releases/tag/0.7
This version fixes an issue with complex bookmark URLs.
Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups
"gol
36 matches
Mail list logo