Skip to content

crhntr/playground

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
cmd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#!/usr/bin/env bash

## UNFORTUNATELY THE SITE AT "https://playground.cazador.codes" IS DONN. I WILL FIX IT WHEN I HAVE TIME.

# Playground

## The functions in this file can be invoked like:
### ./README run

## Setup Dependencies
function init() {
    go mod download
    local assetsDir="cmd/webapp/assets/"
    mkdir -p "${assetsDir}"
    cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" "${assetsDir}"
}

## Build Webapp Assets
function build_webapp() {
  local webappPackage="cmd/webapp"
  local serverPackage="cmd/server"
  rm -rf "${serverPackage}/webapp"
  cp -rf "${webappPackage}" "${serverPackage}"

  GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o "${serverPackage}/webapp/assets/main.wasm" "./${webappPackage}/"
}

## Run
function run() {
  build_webapp
  go run ./cmd/server
}

function deploy() {
  build_webapp
  docker pull golang:alpine
  ko apply --filename cmd/server/deployment.yml
}

if [ $# -ne 0 ]; then
    "$1"
fi

About

A Go playground type thing mostly for WASM!

Topics

Resources

License

Stars

Watchers

Forks