一个 3 层 (前端、API、数据存储) Go Web 应用的示例 (基于驱动 https://sourcegraph.com 的代码)
一个 3 层 (前端、API、数据存储) Go Web 应用的示例 (基于驱动 https://sourcegraph.com 的代码)
thesrc is a news site for programmers that's intended to be an example of how to structure a large Go web app. While this app is not large itself, it demonstrates the same patterns as in the web app that powers Sourcegraph.com.
The web application architecture and patterns demonstrated here were presented in a talk at Google I/O 2014 entitled Building Sourcegraph, a large-scale code search engine in Go. See that talk for more details.
thesrc has a few special features of interest to programmers:
Browse the code on Sourcegraph.
Use the thesrc command to interact with the app.
You can either run it directly:
go get -u sourcegraph.com/sourcegraph/thesrc/...
thesrcOr inside Docker:
docker build -t thesrc && docker run thesrcIf you want to run it in Docker, substitute docker run thesrc for every
instance of thesrc. (Also note that you'll have to pass Docker the necessary
PG* environment variables to connect to the PostgreSQL database.)
First, set the PG* environment variables so that psql works.
Then run these commands to create the DB, import posts from other sites, and classify their links:
# start the server:
thesrc -url=http://localhost:5000 serve
# then, in a separate terminal window, run:
thesrc -url=http://localhost:5000 createdb
thesrc -url=http://localhost:5000 import
thesrc -url=http://localhost:5000 classify
# now open your browser to localhost:5000暂无开放 Issues,或尚未同步最近议题。