Quick Setup
Posted on September 2, 2022
Tags: codeetc
1 Haskell
Creates a new folder helloworld at current directory
stack new helloworld new-template1.1 running
stack run ./app/Main.hs1.1.0.0.1 running interactive
runs an interactive env
stack ghci ./app/Main.hs1.1.0.0.2 build+execute
stack build
stack exec hello-world1.1.1 Go
package main
import (
"fmt"
)
func main() {
var a string = "hello"
var bb []byte = []byte(a[0:3])
var c string = a[1:3]
fmt.Printf("%s\n", a)
fmt.Printf("%s\n", string(bb))
fmt.Printf("%s\n", c)
}go run hello.go1.1.2 Go Modules
project folder
mkdir goworld
cd goworldCreate greetings modules
mkdir greetings
cd greetings
go mod init example.com/greetings
#this creates go.modcreate a file called greetings.go
package greetings
import "fmt"
// Hello returns a greeting for the named person.
func Hello(name string) string {
// Return a greeting that embeds the name in a message.
message := fmt.Sprintf("Hi, %v. Welcome!", name)
return message
}executable folder
cd ..
mkdir hello
cd hello
go mod init example.com/hellopackage main
import (
"fmt"
"example.com/greetings"
)
func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(message)
}setup local
typically our modules will be held on our webserver at (in this case) “example.com/greetings”
To run locally
in your hello dir
go mod edit -replace example.com/greetings=../greetings
go mod tidyrunning
inside hello dir
go run .1.1.3 C
running
gcc -o bleh main.c
./bleh