Chris Ramón

Freelance Software Developer

Read this first

Construyendo una web app con Go desde cero - Parte #2

Construyendo una web app con Go desde cero - Parte 2

En esta segunda parte:

  • Extendemos IndexHandler para que emitir html en vez de text.
  • Aprendemos sobre el control de errores y la estructura de datos map.
package main

import (
    "log"
    "net/http"
    "text/template"
)

func IndexHandler(w http.ResponseWriter, r *http.Request) {
    html := "<h1>{{.Title}}<h1/>"
    t, err := template.New("index").Parse(html)
    if err != nil {
        log.Printf("failed to parse index template, error: %v", err)
        return
    }
    data := map[string]string{
        "Title": "Store App! :)",
    }
    if err := t.Execute(w, data); err != nil {
        log.Printf("failed to execute index template, error: %v", err)
        return
    }
}

func main() {
    log.Println("server running on :8080")
    http.HandleFunc("/", IndexHandler)
    log.Fatal(http.ListenAndServe(":8080", nil))
}
Expl
...

Continue reading →


Construyendo una web app con Go desde cero - Parte #1

Esta es la primera parte de una serie de guías, que describen paso a paso como construir una aplicación web con Go.

La app web que construiremos es una e-commerce, la cual contiene varias características esenciales para aprender:

  • Sintaxis, fundamentos y características importantes de Go.
  • Como resolver problemas comunes en web apps usando Go.

Empecemos!


Creamos el directorio de nuestro proyecto, llamado store (tienda) y seguidamente creamos el archivo principal de nuestro programa, el cual llamaremos main.go, este contendrá el código de nuestro programa que se ejecutará primero.

mkdir store && cd $_ && touch main.go
Explicación:
mkdir store -- Crea el directorio `store`

&& -- Agrupa comandos shell

touch main.go -- Crea el archivo `main.go`

A continuación creamos el servidor web principal de nuestra aplicación, agregamos el siguiente código al archivo main.go.

package
...

Continue reading →


Upgrading minitrello from 0.x to Meteor 1.x

Minitrello is a small meteor demo app which I’ve built for fun several time ago, since is the most stared repo from all my github repos so I think it worthwhile give some attention to it and close issues, so migrating minitrello to 1.x is one of them.

See the full diff version: diff

After upgrading Meteor to 1.1.0.2 and trying to start the app won’t work.

$ meteor
Problem! This project does not have a .meteor/release file. The file should either contain the
release of Meteor that you want to use, or the word 'none' if you will only use the project with
unreleased checkouts of Meteor. Please edit the .meteor/release file in the project and change it
to a valid Meteor release or 'none'.

To fix the previos error:

$ touch .meteor/release

See: https://github.com/meteor/meteor/releases for choosing the release you want to use, then edit .meteor/release file add the release and save:

M
...

Continue reading →