【GoWeb编程】准备起飞

本文详细介绍了如何在macOS环境下进行GoWeb编程,包括Go语言环境安装、dep包管理工具的使用、Postgres数据库的安装、初始化数据脚本的执行以及项目编译与运行。在解决问题部分,提供了针对brew下载缓慢、引用vender包问题和多文件编译问题的解决方案。通过学习,你可以掌握GoWeb开发的基础流程。
摘要由CSDN通过智能技术生成

本文主要思路是根据一个chitchat项目来玩转go语言(项目来源于goweb编程一书) 实现的web基础开发,以及模板文件加载 路由,数据库操作等功能。
运行效果如下

登录页面

主页面
系统环境:macos
使用到的软件:postgres数据库,navicat 数据库客户端工具,Intellij 编译工具,github demo管理

go语言的学习楼主推荐如下学习地址

https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/directory.md

https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/preface.md

Go语言环境安装

安装go的基础编译运行环境 mac brew install go ,或者 也可以直接去官网下载安装包 [官网地址下载] (https://golang.google.cn/dl/) 可根据自己的系统和版本下载对应的安装包

以下这几个环境变量是重点,根据自己下载的go的版本和安装路径进行设置

GOROOT=/usr/local/Cellar/go/1.12.1/libexec
export GOROOT
export GOPATH=/Users/jiangqiaowei/mygo
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN:$GOROOT/bin

GOROOT: go安装目录
GOPATH:go工作目录
其中包括src bin pkg三个子目录 需要自己手动创建,src 为工程目录需要把go的项目放在这个目录中进行编译,bin为引用库目录新建放那就好, pkg打包生成目录新建放那就好
GOBIN:go可执行文件目录
PATH:将go可执行文件加入PATH中,使GO命令与我们编写的GO应用可以全局调用,编辑完之后退出保存文件,然后使用

source ~/.bash_profile 使环境变量生效

设置多个path
mac:

Module 1, Learning Go Web Development, starts off with introducing and setting up Go before you move on to produce responsive servers that react to certain web endpoint. You will then implement database connections to acquire data and then present it to our users using different template packages. Later on, you will learn about sessions and cookies to retain information before delving with the basics of microservices. By the end of this module, we will be covering the testing, debugging, and the security aspect. Module 2, Go Programming Blueprints, has a project-based approach where you will be building chat application, adding authentication, and adding your own profile pictures in different ways. You will learn how Go makes it easy to build powerful command-line tools to find domain names before building a highly scalable Twitter polling and vote counting engine powered by NSQ and MongoDB. Later on it covers the functionalities of RESTful Data Web Service API and Google Places API before you move on to build a simple but powerful filesystem backup tool for our code projects. Module 3, Mastering Concurrency in Go, introduces you to Concurrency in Go where you will be understanding the Concurrency model and developing a strategy for designing applications. You will learn to create basic and complex communication channels between our goroutines to manage data not only across single or multithreaded systems but also distributed systems. Later on you will be tackling a real-world problem, that is, being able to develop a high performance web server that can handle a very large volume of live, active traffic. You will then learn how to scale your application and make it capable of being expanded in scope, design, and/ or capacity. It will then focus on when and where to implement concurrent patterns, utilize parallelism, and ensure data consistency. At the end of this module, we will be logging and testing concurrency before we finally look at the best practices on how to implement complicated and advanced techniques offered by Go.
PHP-For-Go-Web 是用 php bootstrap3 来解析《Go Web 编程》的 md 文件。构建本地或者远程网站。妈妈再也不用担心我的网速了。 从https://github.com/astaxie/build-web-application-with-golang/tree/master/zh 获取md文件 从https://github.com/erusev/parsedown 获取 Markdown 格式数据的 PHP 解析类库 使用 PHP 解析得到 html 数据 使用 Bootstrap 显示最终的html页面 我不生产代码,我是代码的搬运工! 展示站点:http://go.webiji.com 安装配置 [ Apache ] httpd.conf配置文件中加载了mod_rewrite.so模块 AllowOverride None 将None改为 All 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下 <IfModule mod_rewrite.c>  RewriteEngine on  RewriteCond %{REQUEST_FILENAME} !-d  RewriteCond %{REQUEST_FILENAME} !-f  RewriteRule ^(.*)$ index.php?file=$1 [QSA,PT,L] </IfModule> 本项目在wampserver下开发并且通过测试。建议使用wampserver环境。 [ IIS ] 如果你的服务器环境支持ISAPI_Rewrite的话,可以配置httpd.ini文件,添加下面的内容: RewriteRule (.*)$ /index\.php\?file=$1 [I] [ Nginx ] 通过在Nginx.conf中配置转发规则实现: location / { // …..省略部分代码    if (!-e $request_filename) {    rewrite  ^(.*)$  /index.php?file=$1  last;    break;     }  } 如果你的项目安装在二级目录,Nginx的伪静态方法设置如下,其中goweb是所在的目录名称。 location /goweb/ {     if (!-e $request_filename){         rewrite  ^/goweb/(.*)$  /goweb/index.php?file=$1  last;     } } 标签:PHPForGoWeb
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值