Shopping cart in Go
Go HTML PLpgSQL Other
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
db
static
tpl show product image in non-admin mode Sep 28, 2014
.gitignore
README.adoc README localhost Mar 22, 2015
TDD.adoc
TODO
admin.go
admin_orders.go
admin_products.go
admin_user.go remove log.Fatal Sep 28, 2014
helper.go generate image name, sniff mime Sep 28, 2014
main.go
notest.go sqlite foreign key, admin account init, etc. Oct 28, 2013
product.go
user.go

README.adoc

goshop

Prepare go

GOPATH=~/projects/go
mkdir -p $GOPATH
echo "export GOPATH=$GOPATH" >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc
source ~/.bashrc

goshop download

go get github.com/rofrol/goshop
cd $GOPATH/src/github.com/rofrol/goshop

Download css and js

wget http://foundation.zurb.com/cdn/releases/foundation-5.0.3.zip
unzip foundation-5.0.3.zip -d static/foundation
rm foundation-5.0.3.zip

perm

mkdir tls && cd tls
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

Run it

sh db/init.sh
go get .
goshop

Go to https://localhost:9000 and https://localhost:9000/admin (login and password from db/schema.sql)

Go - Managing versions

Q: How about automatic version managment in go? A: Versioning cannot be correctly done automatically for non trivial cases. The trivial cases are few minutes of manual work.

Q: What is the proper way to manage two different versions of the same package A: The name of a package is equivalent to the first number of a semantic version — e.g., a package foo exposes a backward compatible interface always and forever. If a breaking change becomes necessary, the name of the package changes to, e.g., foo2 or something.

Q: where does the convention of package names being the major version come from? That is to use foo, foo2, foo3, etc. A: It comes from Rob Pike and the core Go development team. See the FAQ http://golang.org/doc/faq#get_version . He doesn’t state it like I do though; but, the end result is the same. According to semver, if you make a breaking, incompatible change, you bump the 1st semver number. According to Go community convention, if you make a breaking change, you are advised to call your package a new name. The syntax of the "name" may be different, but the core ideas are the same.

HTTP Redirect

Remember to add return after Redirect, if you want to exit function.

	http.Redirect(w, r, "/admin/products", http.StatusSeeOther)
	return

303 for HTTP 1.1, maybe problem with old corporate proxies, so 302 could be better http://stackoverflow.com/questions/46582/response-redirect-with-post-instead-of-get

The common practice is to redirect only after successful forms. So forms with errors are treated by the same POST request, and so have access to the data. https://groups.google.com/forum/?fromgroups#!msg/golang-nuts/HeAoybScSTU/qxp1H7mWZVYJ