albertlatham.com

Projects


What happens when a non-main package has a main function?

Main Package, Main Function

Suppose we have a main package and a main function:

package main

import "fmt"

func main() {
 fmt.Println("Hello, world")
}

We can call run it from the command line like this:

go run .

and we get the expected output:

Hello, world.

Totallynotmain Package, Main Function

Now we make not-main.go and populate it:

package totallynotmain

import "fmt"

func main() {
 fmt.Println("Hello, not main")
}

Now, when we run go run . again, we get the following output:

package .: found packages main (main.go) and totallynotmain (not-main.go) in ./example

If we try to run something like go run main we get the response

package main: cannot find package "main" in any of:
/usr/lib/go-1.13/src/main (from $GOROOT)
/home/albert/go/src/main (from $GOPATH)

But go run main.go works. And if we try go run not-main.go we get

go run: cannot run non-main package

3D Printer Development

Here lay the trials of mechanical design without a good CAD package, attempts to improve the functionality of my current (non-working) printer, and attempts to build something new.