Skip to content

codemodify/gos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go scripting

  • beautified Go syntax
  • embedded gos.* common sense mini framework to facilitate operations
  • supports full Go code

how to run

  • cat ./samples/01/hello-world.gos | gos
  • gos ./samples/01/hello-world.gos
  • chmod +x ./samples/01/hello-world.gos && ./samples/01/hello-world.gos

how to install

  • go: go install github.com/codemodify/gos@latest
  • curl: curl -LkO https://raw.github.com/codemodify/gos@v1.0.0 && chmod +x gos

where to start

  • check the samples folder
  • start at samples/01/hello-world.gos
  • move to next sample, they build incrementatlly on each other
  • check samples/05/pcp.gos it shows a parallelized version of the CP

beautified Go syntax

  • it is a mix of best parts from Go / JS / Rust
  • below is everything-in-one showcase
#!/usr/bin/env gos

func main() {
	var a = "hello world"
	var b = 1
	var c = 2.0
	var d = true
	var e = {
		"a": a,
		"b": b,
		"c": c,
		"d": d,
	}
	var f = [
		a,
		b,
		c,
		d,
	]
	var g =	gos.Helpers.Strings.Format("%s", "hello world")
	var h = [
		a,
		b,
		c,
		d,
	]

	// first runs BLOCK-A then BLOCK-B
	gos.Flow.Run(()=>{
		//
		// BLOCK-A
		//
		gos.Terminal.Println(a)
		gos.Terminal.Println(b)
		gos.Terminal.Println(c)
		gos.Terminal.Println(d)
	}).Run(()=>{
		//
		// BLOCK-B
		//
		gos.Terminal.Println(e)
		gos.Terminal.Println(f)
		gos.Terminal.Println(g)
		gos.Terminal.Println(h)
	})

	// runs BLOCK-A at the same time with BLOCK-B
	gos.Flow.RunParallel(()=>{
		//
		// BLOCK-A
		//
		gos.Terminal.Println(a)
		gos.Terminal.Println(b)
		gos.Terminal.Println(c)
		gos.Terminal.Println(d)
	}).RunParallel(()=>{
		//
		// BLOCK-B
		//
		gos.Terminal.Println(e)
		gos.Terminal.Println(f)
		gos.Terminal.Println(g)
		gos.Terminal.Println(h)
	}).OnDone(()=>{
		gos.Terminal.Println("PARALLEL CODE DONE")
	})

	gos.Terminal.Println("POST PARALLEL continue")
}

dox - embedded common sense mini framework

  gos.Flow gos.Terminal gos.Exec gos.Helpers

About

Go lang scripting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages