GithubHelp home page GithubHelp logo

Comments (4)

titpetric avatar titpetric commented on May 26, 2024 1

Please try running it with the script provided, like I have (../shell/go). Most likely, the #!/bin/bash line is needed and I'll have to amend the instructions in the book. Something like this:

cp shell/go /usr/local/bin/docker-go
docker-go run hello_world.go

from books.

titpetric avatar titpetric commented on May 26, 2024

There's a "run" script provided in the same chapter1 folder, which works for me:

$ ./run
== go run hello_world.go ==
Hello world!

Which exact docker run command are you running? I'll check the ch1 in the book, perhaps I just need to fix some slightly older example.

Edit: It seems the docker run example in ch1 is okay. I put the same snippets under scripts and tried to run hello world from a script as suggested, and from the expanded docker run command:

$ ../shell/go run hello_world.go
Hello world!
$  docker run --rm=true -it -v `pwd`:/go/src/app -w /go/src/app golang go run hello_world.go
Hello world!

I pushed the "go" script which I mentioned/referenced, but generally you can go into every sample directory and just execute "run" scripts. You can paste exactly which command you are executing so I can spot the issue.

from books.

iampeterbanjo avatar iampeterbanjo commented on May 26, 2024

In ch1 under "Setting up a runner for your Go programs" there are these instructions -

$ docker run --net=party -p 8080:80 --rm=true -it -v `pwd`:/go/src/app -w /go/sr\
c/app golang go "$@"

Save this code snippet as the file ‘go’, make it executable and copy it to your execution path (usually
/usr/local/bin is reserved for things like this).

Using that code snippet to run the hello_world.go is causing the error. I have put it in my path but I run it as docker-go so that I can switch between the two. Using the default go prints Hello World.

With the new script in ../shell/common.sh/ there are no errors but Hello World is not being printed to the screen.

In terms of my setup I'm running Linux Mint 17 and Fish shell but I have also tried the commands in bash with the same results.

from books.

iampeterbanjo avatar iampeterbanjo commented on May 26, 2024

You're right - I added #!/bin/bash to the docker script and now both it and ./run are printing Hello World in bash and fish shell. For consistency I amended the run script as follows:


#!/bin/bash
source ../shell/common.sh

APP="foundations"

FILES=$(ls *.go | sort)
for FILE in $FILES; do
    docker-go.sh run $FILE
done

Thanks for your help

from books.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.