Observando alguns erros nos “imports” remotos via Github para Golang

Criei uma VM em virtualbox, para me aprofundar nos estudos sobre Golang :

http://golang.org/

https://pt.wikipedia.org/wiki/Go_(linguagem_de_programa%C3%A7%C3%A3o)

https://en.wikipedia.org/wiki/Go_(programming_language)

E tive alguns problemas que podem ajudar que está também vendo isso:

root@go-hacking:~/go-hacking# go get github.com/hoisie/web
# cd .; hg clone -U https://code.google.com/p/go.net /usr/lib/go/src/pkg/code.google.com/p/go.net
package github.com/hoisie/web
imports code.google.com/p/go.net/websocket: exec: “hg”: executable file not found in $PATH
root@go-hacking:~/go-hacking# apt-get install hg -y
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package hg

Repare que há alguns sinais para entender melhor os erros, como “E: Unable to locate package hg” e “# cd .; hg clone -U https://code.google.com/p/go.net /usr/lib/go/src/pkg/code.google.com/p/go.net” sendo que hg é um comando de controle de repositórios em Mercurial(hg), então, deve-se instalar o mesmo:

root@go-hacking:~/go-hacking# apt-get install mercurial -y
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
mercurial-common
Suggested packages:
qct kdiff3 kdiff3-qt kompare meld xxdiff tkcvs mgdiff python-mysqldb python-pygments python-openssl
The following NEW packages will be installed:
mercurial mercurial-common
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 2.413 kB of archives.
After this operation, 8.067 kB of additional disk space will be used.
Get:1 http://ftp.br.debian.org/debian/ wheezy/main mercurial-common all 2.2.2-3 [2.320 kB]
Get:2 http://ftp.br.debian.org/debian/ wheezy/main mercurial amd64 2.2.2-3 [93,1 kB]
Fetched 2.413 kB in 8s (271 kB/s)
Selecting previously unselected package mercurial-common.
(Reading database … 76402 files and directories currently installed.)
Unpacking mercurial-common (from …/mercurial-common_2.2.2-3_all.deb) …
Selecting previously unselected package mercurial.
Unpacking mercurial (from …/mercurial_2.2.2-3_amd64.deb) …
Processing triggers for man-db …
Setting up mercurial-common (2.2.2-3) …
Setting up mercurial (2.2.2-3) …

Creating config file /etc/mercurial/hgrc.d/hgext.rc with new version

root@go-hacking:~/go-hacking# go get github.com/hoisie/web
root@go-hacking:~/go-hacking#

Pronto!  Nenhum erro mais de instalação!:)

@firebitsbr

 

Criando um WebServer em Golang

Puxa, vida! Desenvolver em Golang é muito legal e multicore!

Quero me aprofundar mais nessa linguagem assim como Node.js também.

Nos proximos posts, vou falar mais e mais exemplos.

Para instalar o Golang no Debian 7 e executar códigos-fontes em golang, é preciso:

Passo 1 – instalar o golang (pode-se usar via git, mas isso farei em outro post)

#sudo apt-get install -f golang golang-dbg golang-doc golang-go golang-mode golang-src

Passo 2 – Criar um arquivo para nosso Webserver em Golang:

#vim webserver.go

package main

import (
“net/http”
“fmt”
)

// Default Request Handler
func defaultHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, “<h1>Olá mundo %s! by firebits</h1>”, r.URL.Path[1:])
}

func main() {
http.HandleFunc(“/”, defaultHandler)
http.ListenAndServe(“:8080”, nil)
}

Passo 3 – Salvar o arquivo

Passo 4- executando o script via compilador golang:

#sudo go run webserver.go

Passo 5: Abrir um browser

google chrome -> 127.0.0.1:8080

Captura de tela - 04-09-2013 - 12:48:36