Envisioning a Go-Powered Ecosystem: The Ultimate Go Computer

20 Jun 2024

Manfred Touron

VP Eng., Gno.land

Bonjour, GopherCon EU!

package main

import "fmt"

func main() {
    fmt.Println("Hello, GopherCon EU! It's Manfred.")
}
2

Intro

3

What Would a Go Computer Be Like?

Imagine a machine where Go is the only paradigm for all levels of computing:

Disclaimer: These slides present a mental exercise of what such a computer could look like. This is not a critique of current practices, but an exploration of using Go everywhere.

4

Key Concepts

5

No Marshaling

func SomeHandler(w http.ResponseWriter, r *http.Request) {
    data := MyStruct{Field: "value"} // go logic
    _, err := json.NewEncoder(w).Encode(data)
}
func SomeHandler() MyStruct {
    data := MyStruct{Field: "value"}
    return data
}
6

No Flag Parsing

func main() {
    flag.StringVar(&myStringFlag, "stringFlag", "default", "usage")
    flag.IntVar(&myIntFlag, "intFlag", 0, "usage")
    flag.Parse()
    MyFunc(*myStringFlag, *myIntFlag)
}

$> myprogram --stringFlag foo --intFlag 42
$> mypackage.MyFunc("stringValue", 42)
7

No Compilation

// Current approach
// Compile and run the binary from the CLI
// $ go build -o myapp
// $ ./myapp

package main

func main() {
    mypackage.MyFunc()
}
// Unified approach
import "my/package"
mypackage.MyFunc()
8

No FileSystem/Databases

import "database/sql"
db, err := sql.Open("driver", "source")
_, err := db.Exec("CREATE TABLE IF NOT EXISTS users ...")
_, err := db.Exec("INSERT INTO users ...")
rows, err := db.Query("SELECT fields FROM users ...")
defer rows.Close()
for rows.Next() { /* logic */}
err := rows.Err()
type User struct {
    Name string
    Age  int
}
var users []User
users = append(users, User{"John Doe", 30})
for _, user := range users {
    /* logic */
}
9

No main(), no exit

func main() {
    // logic
}
func init() {
    // logic
}
func Foo() {
    // logic
}

$> myprogram.Foo() // resumes, executes, pauses
10

Conclusion

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. -- Antoine de Saint-Exupéry

11

What We're Doing at Gno.land

12

Thank you

Manfred Touron

VP Eng., Gno.land

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)