 
      
    | You are here | damienradtke.com | ||
| | | | | aarol.dev | |
| | | | | TLDR: # http.ListenAndServe(":8080", nil) // bad http.ListenAndServe("localhost:8080", nil) // good If you are using Go with Windows, you might ... | |
| | | | | infinitedigits.co | |
| | | | | A simple pattern to get started using websockets with Go. | |
| | | | | avelino.run | |
| | | | | A linguagem Go é um projeto open source para tornar os programadores mais produtivos. Go foi desenvolvido para utilização maxima do CPU, tornando um processo simples para criar aplicação Multithreaded, o processo de utilização de maquinas na rede para processar determinado programa também é bem simples, assim tornando um software mais flexível e modular. Vamos montar um servidor HTTP em Go. package main import ( "http"; "io"; "fmt"; ) func HelloServer(c *http.Conn, req *http.Request) { io.WriteString(c, "hello, world!\n"); } func main() { fmt.Printf("http://localhost:8080/hello\n"); http.Handle("/hello", http.HandlerFunc(HelloServer)); err := http.ListenAndServe(":8080", nil); if err != nil { panic("ListenAndServe: ", err.String()) } } O HelloServer() é o que vai fazer a parte de renderização, o man() ele sobre o servidor HTTP na porta 8080, e caso o usuário tente processar um URL que não esteja no fmt ele vai cair no err onde vai processar o erro e apresentar o panic. Simples assim já temos um servidor HTTP. | |
| | | | | lanie.dev | |
| | | So you want to parse a form. You have your handler, and you're getting data passed in through the request. 1 2 3 4 5 package example func Login(w http.ResponseWriter, r *http.Request) { // hi (: } The next step is to parse the form on the request. 1 2 3 4 5 6 func Login(w http.ResponseWriter, r *http.Request) { var err error if err := r. | ||