Skip to content

Commit

Permalink
Merge pull request #8 from codecrafters-io/change-program-interface
Browse files Browse the repository at this point in the history
change program interface
  • Loading branch information
rohitpaulk committed Jul 5, 2024
2 parents c422cc1 + a13914d commit bba5105
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 28 deletions.
2 changes: 1 addition & 1 deletion compiled_starters/go/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

# (This file is empty since Go programs don't use a compile step)
go build -o /tmp/interpreter-target ./cmd/myinterpreter
1 change: 1 addition & 0 deletions compiled_starters/go/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

exec /tmp/interpreter-target "$@"
23 changes: 15 additions & 8 deletions compiled_starters/go/your_program.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/sh
#
# DON'T EDIT THIS!
# Use this script to run your program LOCALLY.
#
# CodeCrafters uses this file to test your code. Don't make any changes here!
# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
#
# DON'T EDIT THIS!
set -e
# Learn more: https://codecrafters.io/program-interface

tmpFile=$(mktemp)
# Exit early if any commands fail
set -e

( cd $(dirname "$0") &&
go build -o "$tmpFile" ./cmd/myinterpreter )
# Copied from .codecrafters/compile.sh
#
# - Edit this to change how your program compiles locally
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
go build -o /tmp/interpreter-target ./cmd/myinterpreter

exec "$tmpFile" "$@"
# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/interpreter-target "$@"
7 changes: 6 additions & 1 deletion dockerfiles/go-1.22.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22-alpine

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum"

WORKDIR /app

COPY go.mod go.sum ./
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
RUN GODEBUG="installgoroot=all" go install std

RUN ash -c "set -exo pipefail; go mod graph | awk '{if (\$1 !~ \"@\") {print \$2}}' | xargs -r go get"

# Once the heavy steps are done, we can copy all files back
COPY . /app
2 changes: 1 addition & 1 deletion solutions/go/01-ry8/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

# (This file is empty since Go programs don't use a compile step)
go build -o /tmp/interpreter-target ./cmd/myinterpreter
1 change: 1 addition & 0 deletions solutions/go/01-ry8/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

exec /tmp/interpreter-target "$@"
23 changes: 15 additions & 8 deletions solutions/go/01-ry8/code/your_program.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/sh
#
# DON'T EDIT THIS!
# Use this script to run your program LOCALLY.
#
# CodeCrafters uses this file to test your code. Don't make any changes here!
# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
#
# DON'T EDIT THIS!
set -e
# Learn more: https://codecrafters.io/program-interface

tmpFile=$(mktemp)
# Exit early if any commands fail
set -e

( cd $(dirname "$0") &&
go build -o "$tmpFile" ./cmd/myinterpreter )
# Copied from .codecrafters/compile.sh
#
# - Edit this to change how your program compiles locally
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
go build -o /tmp/interpreter-target ./cmd/myinterpreter

exec "$tmpFile" "$@"
# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/interpreter-target "$@"
2 changes: 1 addition & 1 deletion starter_templates/go/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

# (This file is empty since Go programs don't use a compile step)
go build -o /tmp/interpreter-target ./cmd/myinterpreter
1 change: 1 addition & 0 deletions starter_templates/go/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#
# Learn more: https://codecrafters.io/program-interface

exec /tmp/interpreter-target "$@"
23 changes: 15 additions & 8 deletions starter_templates/go/your_program.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/sh
#
# DON'T EDIT THIS!
# Use this script to run your program LOCALLY.
#
# CodeCrafters uses this file to test your code. Don't make any changes here!
# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
#
# DON'T EDIT THIS!
set -e
# Learn more: https://codecrafters.io/program-interface

tmpFile=$(mktemp)
# Exit early if any commands fail
set -e

( cd $(dirname "$0") &&
go build -o "$tmpFile" ./cmd/myinterpreter )
# Copied from .codecrafters/compile.sh
#
# - Edit this to change how your program compiles locally
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
go build -o /tmp/interpreter-target ./cmd/myinterpreter

exec "$tmpFile" "$@"
# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/interpreter-target "$@"

0 comments on commit bba5105

Please sign in to comment.