[go-nuts] [ANN] Configuration library

2016-07-26 Thread Gerardo Oscar JT
Maybe too simple, maybe there are several solutions, but here https://github.com/fulldump/goconfig is a configuration library to avoid the over-verbosity of flag library. It also allow load configuration from a json file. It works like this: type myconfig struct { Name string `The nam

Re: [go-nuts] What's the correct way to return a pointer to a string in cgo?

2016-07-26 Thread Tamás Gulácsi
retValue:=C.GoString(cRetValue) -- 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.g

Re: [go-nuts] Re: SetKeepAlive TCP server

2016-07-26 Thread djadala
you must also set keepalive period: SetKeepAlivePeriod( time.Minute) On Wednesday, July 27, 2016 at 7:19:24 AM UTC+3, EdgarAlejandro Vintimilla wrote: > > How can I let a conn alive, I have this code, the TCP server work but it > does not keep alive > > > func main() { > // Listen for inco

Re: [go-nuts] Re: SetKeepAlive TCP server

2016-07-26 Thread EdgarAlejandro Vintimilla
How can I let a conn alive, I have this code, the TCP server work but it does not keep alive func main() { // Listen for incoming connections. l, err := net.Listen(CONN_TYPE, CONN_HOST+":"+CONN_PORT) if err != nil { fmt.Println("Error listening:", err.Error()) os.Exi

Re: [go-nuts] syscall.Read() with timeout: syscall.Select() vs golang's select statement

2016-07-26 Thread Sam Vilain
On 7/26/16 4:05 PM, Matt Harden wrote: > Select and epool actually aren't useful for fd's that are opened on > regular files. As I understand it, they always indicate those files > are ready for I/O. That may well be the case for regular files. I'm talking in particular about filehandles which ar

[go-nuts] Can I use ... in switch? (example inside)

2016-07-26 Thread Kevin P
Is this valid? https://play.golang.org/p/xZdOWbm7Ew package main import ( "fmt" ) func main() { a := []int{0,1,2,3,4,5} switch 1 { case a...: fmt.Println("match") default: fmt.Println("no match") } } -- You received this message because you are subscribed to the Google Groups "golang-nuts

Re: [go-nuts] Who wants to use Go to process your camera's raw files?

2016-07-26 Thread Sam Whited
On Tue, Jul 26, 2016 at 9:35 PM, Jonathan Pittman wrote: > Figuring out how to handle this problem for one specific camera's raw files > is not too difficult. Figuring out how to do this to handle the majority of > cases requires a bit more work. I know libraw has its issues (and lots of them),

[go-nuts] Who wants to use Go to process your camera's raw files?

2016-07-26 Thread Jonathan Pittman
Well me too! I am looking to see what level of interest there is in the Go community to see this happen. I am also looking for people who are interested in working on this. Figuring out how to handle this problem for one specific camera's raw files is not too difficult. Figuring out how to do t

Re: [go-nuts] syscall.Read() with timeout: syscall.Select() vs golang's select statement

2016-07-26 Thread Ishwor Gurung
On 27/07/2016 09:05, Matt Harden wrote: > Select and epool actually aren't useful for fd's that are opened on regular > files. As I understand it, they always indicate those files are ready for This is not entirely accurate. The select(2) and epoll(7) _can_ be used on a regular file descriptors; e

[go-nuts] Re: nodemon style tool

2016-07-26 Thread YOU
Goemon works great - https://github.com/mattn/goemon On Tuesday, July 26, 2016 at 2:36:18 AM UTC+9, KLR wrote: > > Hi, is there a nodemon style tool for go (or less bulky) or has anyone a > recommendation for server restart after code changes bash script for that > and watching several files .go

[go-nuts] How to get struct of function

2016-07-26 Thread nakotoffana
Lets say an example function like this func (r *Router) Get(path string, controller interface{}) {} And I am calling it this way Route.Get("/", controllers.Test.IsWorking) Refering to this function type Test struct { Name string } func (t Test) IsWorking() { log.Println("hello") } How c

Re: [go-nuts] What's the correct way to return a pointer to a string in cgo?

2016-07-26 Thread Adyuor
How one would increment cRetValue pointer in go code to access the successive bytes ? *cRetValue gives me the zeroth byte only. How to get the 2nd, 3rd byte? The case I have has a pointer to array of structs in C land and I want to iterate over them in Go. Thanks!! On Sunday, April 17, 2016

Re: [go-nuts] syscall.Read() with timeout: syscall.Select() vs golang's select statement

2016-07-26 Thread Matt Harden
Select and epool actually aren't useful for fd's that are opened on regular files. As I understand it, they always indicate those files are ready for I/O. You may be able to get something working using io_setup and friends on Linux: http://man7.org/linux/man-pages/man2/io_setup.2.html, but that wou

Re: [go-nuts] Re: Best practice for sets in go?

2016-07-26 Thread Dan Kortschak
Very much agree, but also something that has not been explicitly (or at least deeply) said here is the use of a tiny type (when the number of uses warrants - this is salt to taste). type set map[T]struct{} func (s set) has(v T) bool { _, ok := s[v] return ok } func (s set) add(v

Re: [go-nuts] syscall.Read() with timeout: syscall.Select() vs golang's select statement

2016-07-26 Thread Sam Vilain
On 7/24/16 12:49 PM, fabian.stae...@gmail.com wrote: > The idea is obvious: When the timeout is reached, fd is closed, which > interrupts the blocking syscall.Read(), which terminates the goroutine. I'm wondering how to do this safely for filehandles I don't want to close, for instance stdin or st

[go-nuts] Re: Best practice for sets in go?

2016-07-26 Thread Nate Finch
I much prefer struct{}. For gophers, it is very expressive of "nothing to see here".This value has no meaning, so don't even bother with it. And as someone else said, the _, ok pattern is so pervasive, it's no harder for me to read than if myMap[foo] { if _, ok := myMap[foo]; ok { } I t

[go-nuts] nodemon style tool

2016-07-26 Thread Henrique santos
Hi a developed this tool https://github.com/jhsx/devop -- 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,

Re: [go-nuts] Best practice for sets in go?

2016-07-26 Thread Matt Harden
Sets are in an unfortunate situation in Go. They're so easy to create from maps that it's hard to justify creating a special type for them, but the struct{}/bool dichotomy has good arguments on both sides. The result is that there is no idiomatic set type. I'm starting to think that it's best to al

Re: [go-nuts] Best practice for sets in go?

2016-07-26 Thread Edward Muller
I encourage people to use the later form because of the duality of a bool (true or false) and the fact that it implies meaning. When you see the bool you have to start considering the false path. I'd much prefer the extra few bytes for the longer inclusion checks because there is no ambiguity in th

Re: [go-nuts] Best practice for sets in go?

2016-07-26 Thread Jakob Borg
2016-07-26 18:27 GMT+02:00 Tyler Compton : > if _, ok = m[key]; ok { > } > > Is something Go programmers are used to. > > if m[ok] { > } > > Requires that the programmer take a look at the map and its documentation to > see what's going on unless they're already used to that pattern in the code > b

Re: [go-nuts] Re: SetKeepAlive TCP server

2016-07-26 Thread Matt Harden
This is because your conn variable is probably of the type net.Conn (an interface) rather than *net.TCPConn, so the compiler doesn't know that the SetKeepAlive method is available. If you use a type assertion as djadala suggested: conn.(*net.TCPConn).SetKeepAlive then you are telling the compiler t

Re: [go-nuts] Best practice for sets in go?

2016-07-26 Thread Tyler Compton
In my opinion, struct{} should always be used for placeholders. I also use it when sending to a channel where the data itself doesn't matter. struct{} looks gross but it's very expressive in this case and I think most all Go programmers are familiar with its meaning. map[string]bool suggests th

[go-nuts] Re: [cgo] go strings and go pointers

2016-07-26 Thread Uli Kunitz
It is ensured that the C string is deallocated (freed) by SQLite? Otherwise you have a memory leak. Returning a GO string cannot work for two reasons: 1. Go strings are under management of the GC and might reallocate the string memory while the C code is running. 2. Go strings have no

[go-nuts] Re: Best practice for sets in go?

2016-07-26 Thread Uli Kunitz
I concur. Readability of the actions on a bool map is far better than for the struct{} map. The latter would require a custom type to improve readability. On Tuesday, July 26, 2016 at 1:35:01 PM UTC+2, Dave Cheney wrote: > If saving one byte per entry is important for your application, the lat

[go-nuts] [cgo] go strings and go pointers

2016-07-26 Thread Tamás Gulácsi
You have to allocate ön the C side if you pass it to C, esp. pointers. -- 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. F

Re: [go-nuts] Best practice for sets in go?

2016-07-26 Thread Sam Whited
On Tue, Jul 26, 2016 at 6:35 AM, Dave Cheney wrote: > If saving one byte per entry is important for your application, the latter is > your choice. The former has nicer properties that you can use the single > value form of map access, > > if m[key] { >// found > } > > I'd say the former is t

Re: [go-nuts] Re: nodemon style tool

2016-07-26 Thread Josh Kamau
Gin works for me ;) https://github.com/codegangsta/gin On Tue, Jul 26, 2016 at 1:42 PM, KLR wrote: > > thanks Daniel, also found https://github.com/JonahBraun/wago which is > doing the job nicely > > > El lunes, 25 de julio de 2016, 19:36:18 (UTC+2), KLR escribió: >> >> Hi, is there a nodemon s

Re: [go-nuts] Post request from server to site

2016-07-26 Thread Konstantin Khomoutov
On Tue, 26 Jul 2016 04:05:25 -0700 (PDT) apek...@gmail.com wrote: > hi i need to connect via post request to site . What package more > usefull for this ? I m use iris framework for build my service. Iris > use fasthttp lib. Maybe fasthttp helps me ? > > Im create a function where i m send params

[go-nuts] Best practice for sets in go?

2016-07-26 Thread Dave Cheney
If saving one byte per entry is important for your application, the latter is your choice. The former has nicer properties that you can use the single value form of map access, if m[key] { // found } I'd say the former is the right choice for 97.25% of general use cases. -- You received

[go-nuts] Best practice for sets in go?

2016-07-26 Thread bwallace722
Heyo, I'm wondering whether there's any official preference between the following two approaches for implementing a set (of, e.g., strings) in go: greetings := map[string]bool { "hi": true, "hello": true, } greetings := map[string]struct{} { "hi": {

[go-nuts] Re: How to upload a file using golang and ajax

2016-07-26 Thread Sourabh
Nice code! I want to upload file from ios client to webserver. Any advice to extract image file information from client, so that it can be stored in server. On Saturday, February 11, 2012 at 9:45:06 AM UTC+5:30, GGGo wrote: > > You need a web server in Go : > package main > > import ( >

[go-nuts] Re: can't get Content-Type and Content-Disposition to force browser to display "file->save..." dialog in the web browser

2016-07-26 Thread akira . atware
Hello, I'm facing a very similar problem but I still cannot solve it by your solution. Would you mind help me ? Thank you very much On Friday, 24 June 2016 23:57:27 UTC+9, David Marceau wrote: > > The core problem was: > w.Header().Set("Content-Disposition","attachment;filename=" + > strOutputFi

[go-nuts] [cgo] go strings and go pointers

2016-07-26 Thread Miłosz Pigłas
Hello everyone, I'm experimenting with extension for sqlite written in Go. This is simple function exported to shared library, which produces string from recived arguments. If such function returns value (which is result of concatenation of strings that were created in C code) as GO string, pro

[go-nuts] Post request from server to site

2016-07-26 Thread apekoff
hi i need to connect via post request to site . What package more usefull for this ? I m use iris framework for build my service. Iris use fasthttp lib. Maybe fasthttp helps me ? Im create a function where i m send params. On output i need a body of page func goToSite(param string) { #pseudo co

[go-nuts] Re: nodemon style tool

2016-07-26 Thread KLR
thanks Daniel, also found https://github.com/JonahBraun/wago which is doing the job nicely El lunes, 25 de julio de 2016, 19:36:18 (UTC+2), KLR escribió: > > Hi, is there a nodemon style tool for go (or less bulky) or has anyone a > recommendation for server restart after code changes bash scri

[go-nuts] Re: SetKeepAlive TCP server

2016-07-26 Thread djadala
tryconn.(*TCPConn ).SetKeepAlive On Tuesday, July 26, 2016 at 10:04:41 AM UTC+3, EdgarAlejandro Vintimilla wrote: > > > > > when I use the conn.SetKeepAlive i get this error: reference to undefined > field or method ‘SetKeepAlive’ > > https://golang.org/p

[go-nuts] SetKeepAlive TCP server

2016-07-26 Thread EdgarAlejandro Vintimilla
when I use the conn.SetKeepAlive i get this error: reference to undefined field or method ‘SetKeepAlive’ https://golang.org/pkg/net/#TCPConn.SetKeepAlive why? but If I use conn.SetReadDeadline it works ok https://golang.org/pkg/net/#IPConn.SetReadDeadline -- You received this message bec