In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to build Go language and Beego framework environment, aiming at this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Before we start building the environment, let's take a look at:
What are the advantages of Go:
Do not need a virtual machine, it can be directly compiled into machine code, there is no external dependence except glibc, deployment is very convenient, just throw a file to complete.
Naturally support concurrency, can make full use of multi-core, it is easy to achieve concurrency.
25 keywords, but very expressive, supporting almost most of the features you've seen in other languages: inheritance, overloading, objects, etc.
Built-in powerful tools, Go language built-in a lot of tool chains, the best should be gofmt tools, automated formatting code, can make the team review easier.
Cross-platform compilation, if you want to generate executable files on linux on windows, you only need a command (set GOOS=linux), that is, the windows system can compile linux applications.
What is Go suitable for?
Server programming, using Go to do is very appropriate, such as processing logs, data packaging, virtual machine processing, file system, etc.
Distributed systems, database agents, etc.
Network programming, which is currently the most widely used, including Web applications, API applications, download applications
Go successful projects
Nsq:bitly 's open source message queuing system has very high performance. At present, they process billions of messages every day.
Docker: a virtual packaging tool based on lxc, which can realize the construction of PAAS platform.
Packer: used to generate image files for different platforms, such as VM, vbox, AWS, etc., written by vagrant
Skynet: distributed scheduling framework
Doozer: distributed synchronization tool, similar to ZooKeeper
Heka:mazila open source log processing system
Cbfs:couchbase open source distributed file system
Tsuru: open source PAAS platform, which has exactly the same function as SAE
Caching system for Google download system written by groupcache:memcahe author
God: a caching system similar to redis, but supports distribution and extensibility
If you think the Go language is powerful and want to learn it, you can learn about the environment building process with me now.
1. Related software preparation:
Git: an open source distributed version control system that can effectively and quickly handle project version management from very small to very large, divided into 32-bit and 64-bit installation packages.
Go:go language installation package, divided into 32 and 64 bits.
LiteIde: a simple, open source, cross-platform Go language IDE developed by Chinese people.
2. Install the go installation package:
1. Select the corresponding go1.8.3.windows-XXX.msi file according to whether the operating system is 32-bit or 64-bit, double-click to start the installation, and take the next step all the way to complete the installation. When installing to the selected destination folder, you can choose disk D.
2. Configure environment variables. Select computer-> Properties-> Advanced system Settings-> Environment variable to see if there is GOROOT in the system environment variable (by default GOROOT is set up after installation, that is, the installation directory just now). For the convenience of subsequent work, configure GOPATH here and add a GOPATH system variable to the environment variable, as shown in the following figure:
Finally, add "% GOPATH%bin" to the Path (the default go installation package is installed, and this is also set), as shown in the following figure:
And then make sure.
3. Check whether the Go locale has been installed in the console. In windows, use the shortcut key.
Win + R, enter cmd, open the command prompt, enter "go", and the following figure will be available:
By the way, the directory structure of Go programs is under the GOPATH folder, which is divided into three subfolders: bin, pkg, and src.
Bin folder: the binary executable generated by each project in Go. .exe files are generated under windows and executable files are generated under linux. One of the biggest features of Go is portability, that is, when a demo.exe is generated, the exe file can be executed on any windows system (even if the go installation package is not installed). This is beyond the reach of scripting languages such as PHP,Python.
Pkg folder: third-party libraries. Store the third-party libraries referenced in your project (unofficially provided libraries)
Src folder: each subfolder represents a go project in which the source program is stored.
3. The use of LiteIDE, an IDE development tool based on Go language.
Extract the liteidex32.1.windows-qt5 we downloaded, put the liteide folder in your favorite location, find the liteide.exe under the\ LiteIDE\ bin path, a very handsome tai chi icon, and double-click to run it.
For LiteIDE, there are some simple settings: (take the 64-bit version of windows10 as an example)
1. Below, select win64, which determines which platform executable file is generated after compilation. Select win64 here, and the exe file will be generated after compilation.
2. Click the icon below to check whether the path of GOROOT is the installation path of Go.
3. Click the icon below to view the GOPATH to determine whether the system GOPATH is the GOPATH set in the environment variable, and click OK.
Then restart liteIDE.
The IDE made by Daniel Visualfc is really handsome, with intelligent tips and all kinds of debugging, and the speed is also very fast.
4. Git tool installation:
Double-click to install the Git-2.15.1.2-XX-bit.exe we downloaded and install it all the way to the next step. After the installation is complete, you can see the following icon with the right mouse button:
5. Build the Beego framework environment:
Beego is a lightweight application framework written by Chinese Daniel Xie Mengjun. There is a description of this framework in his book "Go Web programming". It is well written.
The address of the project is as follows:
Https://github.com/astaxie/beego
We installed Git earlier, which is going to work.
1. Install beego
Right-click "Git Bash" and enter go get-u-v github.com/astaxie/beego as shown below:
Just wait a minute. After the installation is complete, under the GOPATH path (my path for GOPATH is D:\ SoftwareAndProgram\ program\ Go\ Development), you can see the astaxie folder and the subordinate beego folder under D:\ SoftwareAndProgram\ program\ Go\ Development\ pkg\ windows_amd64\ github.com\ and D:\ SoftwareAndProgram\ program\ Go\ src\ github.com\.
2. Install the bee tool (framework generation tool)
To facilitate the generation of the framework, right-click "Git Bash" and enter go get-u-v github.com/beego/bee, as shown below:
It is also possible to wait for a while. When you are done, you can see the bee folder under the D:\ SoftwareAndProgram\ program\ Go\ Development\ src\ github.com\ beego path.
At the same time, in the src sibling bin under the GOPATH path, there is a "bee.exe" file.
3. Use bee tool to generate the frame engineering code.
Find "Command prompt" in "start", right-click "run as Administrator", go to the bin path of GOPATH, and then enter "bee new Project name", as shown below:
A folder named after the project name is generated under the src directory of GOPATH. The project of such a Beego framework is generated successfully.
4. Use LiteIDE to open and run.
Find the "Open directory" in the "File" of LiteIDE, and find the project folder you just generated, as shown below:
Click Select folder to load the entire project.
The clear MVC is clear at a glance. Ctrl+R compiles and executes. Of course, you can also set breakpoints and debug.
Open the browser and type "http://127.0.0.1:8080"" to see the result of the run.
To finish running, click the small red button after "compile output" on LiteIDE.
This is the answer to the question about how to build the Go language and Beego framework environment. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.