Quick Setup
Posted on September 2, 2022
Tags: codeetc
1 Haskell
Creates a new folder helloworld at current directory
stack new helloworld new-template
1.1 running
stack run ./app/Main.hs
1.1.0.0.1 running interactive
runs an interactive env
stack ghci ./app/Main.hs
1.1.0.0.2 build+execute
stack build
stack exec hello-world
1.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]
.Printf("%s\n", a)
fmt.Printf("%s\n", string(bb))
fmt.Printf("%s\n", c)
fmt}
go run hello.go
1.1.2 Go Modules
project folder
mkdir goworld
cd goworld
Create greetings modules
mkdir greetings
cd greetings
go mod init example.com/greetings
#this creates go.mod
create 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.
:= fmt.Sprintf("Hi, %v. Welcome!", name)
message return message
}
executable folder
cd ..
mkdir hello
cd hello
go mod init example.com/hello
package main
import (
"fmt"
"example.com/greetings"
)
func main() {
// Get a greeting message and print it.
:= greetings.Hello("Gladys")
message .Println(message)
fmt}
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 tidy
running
inside hello dir
go run .
1.1.3 C
running
gcc -o bleh main.c
./bleh