Entorno de ejecución
Herramientas estándar
Servidor HTTP
API Rest
Pruebas
func Handle(pattern string, handler Handler)
func ListenAndServe(addr string, handler Handler) error
import ( "io" "log" "net/http")func main() { // Hello world, the web server helloHandler := func(w http.ResponseWriter, req *http.Request) { io.WriteString(w, "Hello, world!\n") } http.HandleFunc("/hello", helloHandler) log.Fatal(http.ListenAndServe(":8080", nil))}
GET /get/key
GET /set/key/value
GET /delete/key
make(map[string]string)
mux sync.Mutex
Carpeta independiente
Funciones en mayúscula exportadas
Importado desde fuera
Crea un paquete memcached
Añade las funciones para set, get, delete
Accede al paquete desde el servidor
func TestAbs(t *testing.T)
func Get(url string) (resp *Response, err error)
By Alex Fernández
Curso de Go básico para Kairos DS, 2019-03, día 2/2.