Go, also called golang, is an open source programming language initially developed at Google. It is a statically-typed language with syntax loosely derived from that of C, adding automatic memory management, type safety, some dynamic-typing capabilities, additional built-in types such as ...

learn more… | top users | synonyms (2)

0
votes
1answer
5 views

Go equivalent to OpenSSL EVP symmetric EVP_aes_256_cbc

I'm writing a Go script that will decrypt some legacy data that is encrypted with EVP_aes_256_cbc and an RSA public key. In C this would be something like: key_size = EVP_OpenInit(&ctx, ...
0
votes
1answer
7 views

syscall.Sockaddr Type Assertion

I am opening a Linux packet socket and trying to read received packets into a struct: type msg struct { n, oobn, flags int p, oob []byte from syscall.Sockaddr } socket, err := ...
1
vote
1answer
52 views

Is there java.io.Reader equivalent in Go?

Go has very nice io.Reader and io.Writer interfaces, that roughly correspond to java.io.InputStream and java.io.OutputStream classes in Java (i.e. Reader = stream of bytes, Writer = sink for bytes). ...
-3
votes
0answers
25 views

who either has the qual webframwork [on hold]

I am planing to write a web application and try to find out, which framework is suitable for me. First of all, I was sure to use martini webframework but after this article Three reasons you should ...
1
vote
2answers
46 views

Why does this golang function _not_ run forever?

I wanted to try the FizzBuzz test (Why can't programmers program), and used Go. It's basically looping from 1 to 100, and printing "Fizz" when the loop counter is divisible by 3, "Buzz" when divisible ...
0
votes
2answers
33 views

How can I concatenate data from a few files of one package in Golang?

For example, structure: /src main.go /test test1.go test2.go , main.go package main import ( "fmt" "./test" ) func main(){ fmt.Println(test.A) } test1.go: ...
2
votes
1answer
38 views

Track and show downloading file summary ( in percentage ) - Go lang

I'm doing a process that downloads a file via a url parameter passed. download is being done properly but what i cant do is to print a summary of the percentage of download done. ( every second ) ive ...
4
votes
1answer
44 views

Can goroutine like erlang spawn process across multiple hosts transparently?

It is said that if configured erlang with cookie setting, the erlang's process could be run across different machines, and this is transparent to the caller. Is that possible for goroutine run like ...
-2
votes
3answers
62 views

Using Golang to build a server but have issue in client side

This is my code: package main import ( "fmt" "net" "net/http" "os" ) const RECV_BUF_LEN = 1024 func handler(w http.ResponseWriter, r *http.Request) { ...
3
votes
1answer
43 views

golang recover return value syntax

I'm trying to understand how to recover from panic situation. Normally, something like this will do: if r := recover(); r != nil { fmt.Println("Recovered in f", r) } I can understand those ...
1
vote
2answers
41 views

Golang: How to pad a number with zeros when printing?

How can I print a number or make a string with zero padding to make it fixed width? For instance, if I have the number 12 and I want to make it 000012.
1
vote
1answer
26 views

lib/pq connects but query fails with bad connection

I'm running a fresh install of Ubuntu 14.04 from Digital Ocean. I've installed Postgres by calling sudo apt-get install postgresql postgresql-contrib. I installed the Postgres driver by calling go get ...
0
votes
3answers
44 views

How do you add spaces to exec.command in golang

How do I use exec.command to start a file with spaces? Adding quotes doesn't seem to work, neither does " or %20 instead of the spaces. package main import ( "fmt" "os/exec" ) func main() { ...
2
votes
3answers
72 views

Designing Go packages: when I should define methods on types?

Suppose that I have a type type T intand I want to define a logic to operate on this type. What abstraction should I use and When ? Defining a method on that type: func (T t) someLogic() { // ...
0
votes
2answers
21 views

Postgres sqlx prepared statement with table name bindvar

I am trying to create a prepared statement in using the Golang sqlx library. I want to have the table name be a bindVar stmt, err := stmtTx.Preparex("SELECT * FROM $1 WHERE question_id=$2;") ...
2
votes
4answers
83 views

How to print numbers in desired order

I found many tutorials in internet about mutex, then after i try to build my own sample. Look at my following code snippet. package main import ( "fmt" "sync" "time" ) func main() { ...
1
vote
1answer
80 views

Slicing operation causing buffer overrun and leaking user passwords?

I have a server that has a function to return the registration date of a user. Any user can see any non-hidden user (in this example only user2 is hidden). The server gets a dateRequest from a client ...
0
votes
2answers
31 views

Golang - Hiding empty struct from JSON Response

I'm trying to make the Error and Success struct disappear if either one of them is empty package main import ( "encoding/json" "net/http" ) type appReturn struct { Suc *Success ...
1
vote
2answers
59 views

Accessing embedded methods in GoLang

I'm trying to create some generic functions in go that handle lots of different object types, some of the types embed a handy sub type I've created call BaseObject. I can't seem to figure out how to ...
-1
votes
1answer
41 views

Golang - how Struct in internal be implemented?

I'm quite confusing about the struct in Go. This is the code: http://play.golang.org/p/b1NEh7JZoK Why I could't get the address of a variable to a struct? If I have two int variables, one stores ...
0
votes
1answer
32 views

go install in golang not creating sub package archives

I have created a package named go-orm in golang and its structure is follows. go-orm --| mine.go --| src -----| src.go -----| db --------| DBConnection.go When I ran the command "go install" in ...
0
votes
0answers
30 views

GO, GAE, remote api and local datastore

I am completely new to GAE using Go (actually using anything. new to GAE). and I am completely lost. I have a small application, whose yaml file looks like this application: my-niceapp-636 version: ...
1
vote
1answer
33 views

Subclassing an object in a different package in golang

I'm trying to create a base object for all my structs in golang. For some reason I can't get it to work when the new object I create is in a different package. It works fine when they are in the same ...
3
votes
1answer
41 views

Golang: readsym out of sync

When I run my GoLang program it throws me this exception: packages/go-lang/1.3/pkg/tool/linux_amd64/6l: readsym out of sync Does it come from my amd64 which would not be supported by the module of ...
1
vote
3answers
43 views

Validate request before downloading

I am trying to create a webservice which will send and receive large files, as part of a storage solution for remote backups. When a request is received by the webserver it needs to be authenticated ...
2
votes
1answer
52 views

Name of a struct to a string

How do I print the name of the type of a struct, i.e. so I can include it in a print statement, i.e. something like type MyStruct struct { ... } func main() { fmt.Println(MyStruct.className()) } ...
1
vote
1answer
50 views

Golang debug using GDB?

I got 2 questions about GDB + golang? 1) Go build GCC flags when I run "go build" , which gcc flags do the Go builder use to build a program? The build value is same as the "GOGCCFLAGS" set in ...
1
vote
1answer
17 views

Golang - Why this error happened in ServeHTTP Function : reflect: call of reflect.Value.Call on zero Value

My code and error message are in here: https://gist.github.com/WithGJR/a700e5d5bd35b5c8eef2 Could anyone explain for me why this error occured and how to fix it? Thanks.
4
votes
2answers
49 views

Go: Reading a specific range of lines in a file

I mainly need to read a specific range of lines in a file, and if a string is matched to an index string (let's say "Hello World!" for example) return true, but I'm not sure how to do so. I know how ...
-1
votes
1answer
59 views

How can you create your own array of colors in google go?

I don't want to use the standard color palettes in the go language, so I am wondering how can you create your own color palette.
1
vote
1answer
62 views

Testing Stdout with go and ginkgo

here I am making my first steps in go trying to do BDD on a go command line app. I am using Ginkgo, which wraps testing.go and lets you do more expressive BDD. https://github.com/onsi/ginkgo I am ...
0
votes
1answer
48 views

How To Authenticate Across Subdomains

I'm working on a web application which actually consists of two applications under the hood. One application is called account and handles all things related to user accounts such authentication, ...
1
vote
1answer
32 views

golang - codecoverage always shows coverage: 0.0% of statements

I created one sample go project and created a unit test cases for the same (In Linux environment, go1.3 version) When i ran go test the output would be PASS ok supported_db 0.201s ...
5
votes
1answer
84 views

How do you set the application icon in golang?

I've just created my first go application on Windows. How do I give it an icon? There doesn't seem to be any build flags to do this, and I know golang doesn't support resources.
4
votes
2answers
66 views

Why does inline instantiation of variable requires explicitly taking the address of it to call pointer method, while for a existing var its implict

Is there a reason for this behaviour? I would like to know what is different in the memory level. The compiler returns "cannot take the address of composite literal" while i can explicitly ask it to ...
0
votes
2answers
37 views

Print type of a structure without creating its instance

In Go, I can print a type of a structure by fmt.Printf("%T",Struct{}) however this creates a new structure and hence taking up a memory. So I may just print fmt.Printf("main.Struct"), but then suppose ...
2
votes
1answer
42 views

Golang - Timestamp losing year after formatting and storage

I am using the Go runtime to store entities in the Appengine Datastore sequenced by the time they were added; to store the timestamp in the key I am formatting the timestamp using the ...
1
vote
1answer
35 views

Setup golang environment using jetbrains

I have setup an golang developing envionemnt using idea (13.1 community edition). It seems the SDK is recognized. However, I could not create a GO file by right click the "New" under the source ...
2
votes
2answers
50 views

issue with accessing GET parameters net/http in golang

Following is my go program to extract GET parameters. (URL: /mysql?hostname=example.com) package main import ( "net/http" "fmt" //"encoding/json" //"html" ...
0
votes
1answer
32 views

Exec.Command Interrupt

I'm writing an application that will run as a daemon on ubuntu 14.04. The purpose of this daemon is to run a for loop that will check for data in various database tables and if data is present it will ...
2
votes
3answers
44 views

Abstract data type constructor can be accidentally bypassed?

I'm trying to make an abstract data type representing a positive number: package m type positiveNum int func MakePositiveNum(i int) positiveNum { if i < 1 { panic("non positive number") } ...
0
votes
1answer
26 views

App Engine for Go app update not reflecting

Using Google App Engine for Go. I have successfully deployed my project update, but it is not reflected back on the Web URL. Does anyone have any idea about that? I have tried Updating it twice. ...
1
vote
1answer
46 views

(un)marshalling json golang not working

I'm playing with go and am stumped as to why json encode and decode don't work for me I think i copied the examples almost verbatim, but the output says both marshal and unmarshal return no data. ...
2
votes
2answers
50 views

How to install Hugo?

I have downloaded and unzipped the hugo_0.11_linux_amd64.tar.gz file from the releases page, and I cannot figure out how to run the binary. I took a few stabs at using go run, and sh, but no luck. Can ...
2
votes
1answer
51 views

Golang: Can I cast to chan interface{}

I am trying to write a general purpose wrapper for subscriptions, something like: type Subscriber interface{ Subscribe(addr string) chan interface{} } Suppose there is a library I want to use ...
-2
votes
1answer
60 views

Image processing with Go and Nodejs [on hold]

I'm on a project where the user can upload images to our server. We are using nodejs, but I would like to use Go for image processing. I would like to know is it possible to 'connect' nodejs with Go, ...
3
votes
4answers
76 views

Constant 1 truncated to integer?

Why wont this code compile? package main const a = 1.000001 const base = 0 const b = a+base func main() { f(b) } func f(int) {} $ go run a.go # command-line-arguments ./a.go:4: constant 1 ...
0
votes
2answers
51 views

Converting json to slice of maps and slice of maps to json in Go without using structs

I am trying to convert a json string from an http request to a slice of map/s. And I should also convert a slice of map/s to json string to use for a http response. I want to convert the followings ...
3
votes
1answer
67 views

Go: Get a set of unique random numbers

How do I get a set of random numbers that are not repeated in the set? Go: for i := 0; i < 10; i++ { v := rand.Intn(100) fmt.Println(v) } This gives me, sometimes, two or three of the ...
1
vote
2answers
76 views

How to write a simple custom http server in Go?

I am new to Go and trying to write a custom http server.Getting compilation error. How can I implement the ServeHTTP method in my code? My Code: package main import ( "net/http" ...