package main
      
      import (
        "fmt"
        "net/http"
        "time"
      )
      
      func greet(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello World! %s", time.Now())
      }
      
      func main() {
        http.HandleFunc("/", greet)
        http.ListenAndServe(":8080", nil)
      }

      Go language logohello world web app

      Go Code Snippets

      The code declares a package named main and imports the fmt and net/http packages. Next, the function greet is created and it takes two arguments, w and r. The first argument, w, is used to write to and the second argument, r, is used to write to. The function prints "Hello World! 9:21" to the console.

      Shortcut: helloweb

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.