go

How do I add the go language to gitg's list of viewable sources?

Hoping a 'git' guru will help out here. I am just beginning to "git" for the first time and have (among other things :-) ) git and gitg installed from Ubuntu 10.4 / AMD64 distribution (ie. maybe not 'latest' version but not ancient). I am trying to look at the go code I've committed via gitg and in the "tree tab" it says: Cannot dis...

Go - Access to another struct by value or by pointer

What difference there is when you access to another struct by value or by a pointer? When should be used each one of them? type foo_ struct { st uint8 nd uint8 } type bar struct { rd uint8 foo foo_ } type barP struct { rd uint8 foo *foo_ } ...

Go - Concurrent method

How to get a concurrent method? type test struct { foo uint8 bar uint8 } func NewTest(arg1 string) (*test, os.Error) {...} func (self *test) Get(str string) ([]byte, os.Error) {...} I think that all code for method Get() should be put inner of go func(), and then to use a channel. func (self *test) Get(str string) ([]byte...

Go programming: How to get from cgo to exe

From a basic test program. . . package main /* #include <stdio.h> static void test() { printf("hello world"); } */ import "C" func main() { C.test(); } I do "cgo hello_cgo.go" and get: _cgo_.o _cgo_defun.c _cgo_gotypes.go hello_cgo.cgo1.go hello_cgo.cgo2.c How do I go about compiling from here to an exe? ...

Go - Generic function using an interface

Since I've a similar function for 2 different data types: func GetStatus(value uint8) (string) {...} func GetStatus(name string) (string) {...} I would want to use a way more simple like: func GetStatus(value interface{}) (string) {...} Is possible to create a generic function using an interface? The data type could be checked usin...

Go - Pointer to map

Having some maps defined as: var valueToSomeType = map[uint8]someType{...} var nameToSomeType = map[string]someType{...} I would want a variable that points to the address of the maps (to don't copy all variable). I tried it using: valueTo := &valueToSomeType nameTo := &nameToSomeType but at using valueTo[number], it shows internal...

What's the best way to get the path of the executable during runtime?

If my go program can be executed in different ways (cron, monit, etc..), what's the most reliable way to get the directory that contains the executable, during runtime? In python, this would be the variable: os.path.realpath(__file__) ...

can anybody suggest go-lang container for simple and fast FIFO stack

can anybody suggest go-lang container for simple and fast FIFO stack, go have 3 different container pkg heap, list and vector. which is more suitable to implement FIFO stack? thanks. ...

Go - Raise an exception

I would want to raise an exception as it's made in Python or Java --to finish the program with an error message--. An error message could be returned to a parent function: func readFile(filename string) (content string, err os.Error) { content, err := ioutil.ReadFile(filename) if err != nil { return "", os.ErrorString("...

Go - Methods of an interface

Would be correct the next way to implement the methods attached to an interface? (getKey, getData) type reader interface { getKey(ver uint) string getData() string } type location struct { reader fileLocation string err os.Error } func (self *location) getKey(ver uint) string {...} func (self *location) getData() ...

Can the GO programming language be used for web apps?

Hey everyone, I have searched the web trying to find some tutorials for the GO programming language that show how to program web apps, but I have not found anything. I was just wondering if it is possible to write web apps with the GO programming language? And if so, is it a good language to write web apps with? Thanks for any help! M...

How do Go web apps function from a server perspective?

Hey Everyone, I followed the directions on how to create web applications using Go, and I was able to get an application working great. One thing I am confused about though is, when you run the application (./8.out), the terminal will sit there and listen on port 8080 until somebody accesses a page. Does the terminal need to stay up ...

Why does Go not seem to recognize size_t in a C header file?

I am trying to write a go library that will act as a front-end for a C library. If one of my C structures contains a size_t, I get compilation errors. AFAIK size_t is a built-in C type, so why wouldn't go recognize it? My header file looks like: typedef struct mystruct { char * buffer; size_t buffer_size; size_t *...

Best way to organize a Go interface

Hey Everyone, Its been a long time since I have programmed in C++, but I know that in C++ the classes are organized into .h files and .cpp files. Also many other languages benefit from splitting up code into logical groupings within a directory structure to improve organization. Well I am trying to learn Go now and I was reading over t...

Unix Sockets in Go

I'm trying to make a simple echo client and server that uses Unix sockets. In this example, the connection seems to be unidirectional. The server can receive data from the client, but it can't send the data back. If I use tcp connections instead, it works great. Does anyone know what's wrong? Server package main import "net" import "f...

web.go install error

Hey Everyone, I am trying to install web.go using goinstall github.com/hoisie/web.go, and I keep getting an error about the path. goinstall: github.com/hoisie/web.go: git: no such file or directory goinstall is working for sure because when I type in just goinstall I get the options list for it. Any ideas on what I am doing wrong? M...

how to allocate array of channels in go

Sorry for the novice syntax question. How do how create an array of channels in go? var c0 chan int = make(chan int); var c1 chan int = make(chan int); var c2 chan int = make(chan int); var c3 chan int = make(chan int); var c4 chan int = make(chan int); That is, replacing the above five lines in one array of channels of siz...

Import web.go error after using goinstall

With halfdans advice, I was successfully able to use goinstall github.com/hoisie/web.go without any errors after installing git first. However, now when I try to compile the sample code given, go is not finding the web package. I get the error, main.go:4: can't find import: web On this code package main import ( "web" ) func he...

Whats for to use Go

I am interested in new language from Google, Go. I have checked the materials in the golang.com. And now want to use Go in practice. Please share any ideas whats for you are using Go. Or are there any open source Go projects that it would be possible to join? ...

Implementing ICMP ping in Go

Is it possible to implement an ICMP ping in Go? The alternative is to fork a 'ping' process, but I'd rather write it in Go. ...