Giter Site home page Giter Site logo

heroku / go-getting-started Goto Github PK

View Code? Open in Web Editor NEW
245.0 97.0 348.0 7.85 MB

Getting Started with Go on Heroku.

Home Page: https://devcenter.heroku.com/articles/getting-started-with-go

Go 46.09% Dockerfile 53.91%
heroku golang go heroku-languages

go-getting-started's Introduction

go-getting-started

A barebones Go app, which can easily be deployed to Heroku.

This application supports the Getting Started with Go on Heroku article - check it out.

Running Locally

Make sure you have Go version 1.17 or newer and the Heroku CLI installed.

$ git clone https://github.com/heroku/go-getting-started.git
$ cd go-getting-started
$ go build -o bin/go-getting-started -v . # or `go build -o bin/go-getting-started.exe -v .` in git bash
github.com/mattn/go-colorable
gopkg.in/bluesuncorp/validator.v5
golang.org/x/net/context
github.com/heroku/x/hmetrics
github.com/gin-gonic/gin/render
github.com/manucorporat/sse
github.com/heroku/x/hmetrics/onload
github.com/gin-gonic/gin/binding
github.com/gin-gonic/gin
github.com/heroku/go-getting-started
$ heroku local

Your app should now be running on localhost:5000.

Deploying to Heroku

Using resources for this example app counts towards your usage. Delete your app and database as soon as you are done experimenting to control costs.

By default, apps use Eco dynos if you are subscribed to Eco. Otherwise, it defaults to Basic dynos. The Eco dynos plan is shared across all Eco dynos in your account and is recommended if you plan on deploying many small apps to Heroku. Learn more about our low-cost plans here.

Eligible students can apply for platform credits through our new Heroku for GitHub Students program.

$ heroku create
$ git push heroku main
$ heroku open

or

Deploy

Documentation

For more information about using Go on Heroku, see these Dev Center articles:

go-getting-started's People

Contributors

bernerdschaefer avatar dependabot[bot] avatar edmorley avatar gocs avatar hackebrot avatar jhubert avatar jonmountjoy avatar jonnymacs avatar joshwlewis avatar natebeck avatar ntassone avatar rodrigozrusso avatar schneems avatar tt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-getting-started's Issues

Make minimal Go configuration

Hey! Could you please provide a minimal Go with Heroku configuration? I try to use this configuration but it seems that there are some not important files and other are not clear enough. I have my main function in cmd/water.go file. When I try to reach the app some error occures. Could you please help me with this problem? Here are the logs:

2019-10-16T11:58:59.163265+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-16T11:58:59.911622+00:00 heroku[web.1]: Starting process with command `bin/cmd`
2019-10-16T11:59:03.007117+00:00 heroku[web.1]: Process exited with status 0
2019-10-16T11:59:03.063997+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-16T12:39:57+00:00 app[api]: Build started by user ###
2019-10-16T12:40:10.169412+00:00 app[api]: Deploy 982a1968 by user ###
2019-10-16T12:40:10.169412+00:00 app[api]: Release v5 created by user ###
2019-10-16T12:40:11.783642+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-16T12:40:12.441753+00:00 heroku[web.1]: Starting process with command `go run cmd/main.go`
2019-10-16T12:40:14.68869+00:00 heroku[web.1]: Process exited with status 127
2019-10-16T12:40:14.734445+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-16T12:40:14.738087+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-16T12:40:14.607402+00:00 app[web.1]: bash: go: command not found
2019-10-16T12:40:15.551851+00:00 heroku[web.1]: Starting process with command `go run cmd/main.go`
2019-10-16T12:40:17.981457+00:00 heroku[web.1]: Process exited with status 127
2019-10-16T12:40:18.040372+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-16T12:40:17.886961+00:00 app[web.1]: bash: go: command not found
2019-10-16T12:40:24.042815+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=###.herokuapp.com request_id=### fwd="###" dyno= connect= service= status=503 bytes= protocol=https
2019-10-16T12:40:24.274562+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=###.herokuapp.com request_id=### fwd="###" dyno= connect= service= status=503 bytes= protocol=https

Error when running locally on Windows

I'm following the steps described in the README on Windows 10, in git bash, but the last command gives me an error.

Here's my full console output:

$ git clone https://github.com/heroku/go-getting-started.git
Cloning into 'go-getting-started'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 1351 (delta 0), reused 0 (delta 0), pack-reused 1347
Receiving objects: 100% (1351/1351), 5.25 MiB | 3.32 MiB/s, done.
Resolving deltas: 100% (541/541), done.
$ cd go-getting-started
$ go build -o bin/go-getting-started.exe -v .
go: downloading github.com/heroku/x v0.0.0-20171004170240-705849e307dd
go: downloading github.com/gin-gonic/gin v0.0.0-20150626140855-4cc2de6207f4
go: extracting github.com/heroku/x v0.0.0-20171004170240-705849e307dd
go: extracting github.com/gin-gonic/gin v0.0.0-20150626140855-4cc2de6207f4
go: downloading github.com/mattn/go-colorable v0.0.0-20150625154642-40e4aedc8fab
go: downloading github.com/manucorporat/sse v0.0.0-20150604091100-c142f0f1baea
go: downloading golang.org/x/net v0.0.0-20150629084131-d9558e5c97f8
go: downloading gopkg.in/bluesuncorp/validator.v5 v5.9.1
go: extracting github.com/mattn/go-colorable v0.0.0-20150625154642-40e4aedc8fab
go: extracting github.com/manucorporat/sse v0.0.0-20150604091100-c142f0f1baea
go: downloading github.com/mattn/go-isatty v0.0.0-20150814002629-7fcbc72f853b
go: extracting gopkg.in/bluesuncorp/validator.v5 v5.9.1
go: extracting github.com/mattn/go-isatty v0.0.0-20150814002629-7fcbc72f853b
go: extracting golang.org/x/net v0.0.0-20150629084131-d9558e5c97f8
go: finding github.com/heroku/x v0.0.0-20171004170240-705849e307dd
go: finding github.com/gin-gonic/gin v0.0.0-20150626140855-4cc2de6207f4
go: finding gopkg.in/bluesuncorp/validator.v5 v5.9.1
go: finding github.com/manucorporat/sse v0.0.0-20150604091100-c142f0f1baea
go: finding github.com/mattn/go-colorable v0.0.0-20150625154642-40e4aedc8fab
go: finding github.com/mattn/go-isatty v0.0.0-20150814002629-7fcbc72f853b
go: finding golang.org/x/net v0.0.0-20150629084131-d9558e5c97f8
github.com/mattn/go-isatty
gopkg.in/bluesuncorp/validator.v5
golang.org/x/net/context
github.com/heroku/x/hmetrics
github.com/manucorporat/sse
github.com/gin-gonic/gin/render
github.com/mattn/go-colorable
github.com/heroku/x/hmetrics/onload
github.com/gin-gonic/gin/binding
github.com/gin-gonic/gin
github.com/heroku/go-getting-started
$ heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
12:13:37 PM web.1 |  'bin' is not recognized as an internal or external command,
12:13:37 PM web.1 |  operable program or batch file.
[DONE] Killing all processes with signal  SIGINT
12:13:37 PM web.1 Exited with exit code null

I have Go 1.13 installed:

$ go version
go version go1.13 windows/amd64

unable to access config var values (.env) from code in GO

D:\server\go>go build -o bin/go-getting-started -v .
github.com/heroku/go-getting-started
# github.com/heroku/go-getting-started
.\main.go:44:38: undefined: repeat

https://devcenter.heroku.com/articles/getting-started-with-go#define-config-vars
router.GET("/repeat", repeatHandler(repeat))

at this link is explained how to do for many supported languages
https://devcenter.heroku.com/articles/config-vars#accessing-config-var-values-from-code

Can't Push to Heroku Master

Hi I'm attempting to push to heroku master and am unable to do so. Here is the error I run into:

`-----> Running: go install -v -tags heroku -mod=vendor github.com/heroku/go-getting-started
remote: build github.com/heroku/go-getting-started: cannot load github.com/russross/blackfriday: open /tmp/build_2941e2439393141fef10a7281ac13d79/vendor/github.com/russross/blackfriday: no such file or directory

remote: ! Push rejected, failed to compile Go app.`

Any ideas of what this could be? Thank you in advance.

Linux Local Build results in a runtime error: index out of range [2097386] with length 242

Following the provided instructions page results in this error.

git clone https://github.com/heroku/go-getting-started.git

cd go-getting-started

go version
(returns)

go version go1.18.2 linux/amd64

go build -o bin/go-getting-started -v .
(returns the following)

github.com/gin-gonic/gin/internal/bytesconv
github.com/go-playground/locales/currency
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/set
golang.org/x/sys/internal/unsafeheader
google.golang.org/protobuf/internal/pragma
github.com/go-playground/locales
golang.org/x/crypto/sha3
google.golang.org/protobuf/internal/detrand
github.com/gin-gonic/gin/internal/json
google.golang.org/protobuf/internal/version
github.com/leodido/go-urn
golang.org/x/sys/unix
gopkg.in/yaml.v2
github.com/heroku/x/hmetrics
github.com/gin-contrib/sse
github.com/ugorji/go/codec
github.com/go-playground/universal-translator
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/encoding/protowire
github.com/heroku/x/hmetrics/onload
google.golang.org/protobuf/reflect/protoreflect
github.com/go-playground/validator/v10
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/order
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/proto
github.com/mattn/go-isatty
google.golang.org/protobuf/internal/encoding/defval
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/descriptorpb
google.golang.org/protobuf/reflect/protodesc
github.com/golang/protobuf/proto
github.com/gin-gonic/gin/binding
github.com/gin-gonic/gin/render
github.com/gin-gonic/gin
github.com/heroku/go-getting-started
# github.com/heroku/go-getting-started
panic: runtime error: index out of range [2097386] with length 242

goroutine 1 [running]:
cmd/link/internal/loader.(*Loader).resolve(0x1720?, 0xc000afec00?, {0x512000?, 0xc0?})
	/usr/lib/go-1.18/src/cmd/link/internal/loader/loader.go:659 +0x1c5
cmd/link/internal/loader.Reloc.Sym({0x7f583c73e06e?, 0xc000afec00?, 0xc000512000?})
	/usr/lib/go-1.18/src/cmd/link/internal/loader/loader.go:59 +0x35
cmd/link/internal/loader.(*Loader).UndefinedRelocTargets(0xc000512000, 0x1)
	/usr/lib/go-1.18/src/cmd/link/internal/loader/loader.go:2465 +0x1a5
cmd/link/internal/ld.(*Link).loadlib(0xc000116000)
	/usr/lib/go-1.18/src/cmd/link/internal/ld/lib.go:600 +0x5d7
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0x0, 0x0}, {0x67f58a, ...}, ...})
	/usr/lib/go-1.18/src/cmd/link/internal/ld/main.go:261 +0xe2b
main.main()
	/usr/lib/go-1.18/src/cmd/link/main.go:69 +0xfe5

From what I understand this error means that the compiler is trying to access an index (2097386) that is out of range (242).

Not exactly sure which int value to fix, or if even changing a specific int value will fix the issue considering there are 790 files.

I also noted the path ./vendor/ has no github.com/heroku/go-getting-started file or directory.
This could also be the point of failure.

Missing `dep init` step

Otherwise the go buildpack doesn't recognize it as a go app.

Also metadata.heroku["root-package"] is needed in Gopkg.toml.

e.g. in my case:

[metadata.heroku]
  root-package = "github.com/localhostdotdev/mitmengine-web"

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.