1、Go作為Google2009年推出的語言,其被設計成一門應用于搭載 Web 服務器,存儲集群或類似用途的巨型中央服務器的系統編程語言。

成都創新互聯主營安居網站建設的網絡公司,主營網站建設方案,成都app軟件開發公司,安居h5微信小程序搭建,安居網站營銷推廣歡迎安居等地區企業咨詢
2、對于高性能分布式系統領域而言,Go 語言無疑比大多數其它語言有著更高的開發效率。它提供了海量并行的支持,這對于游戲服務端的開發而言是再好不過了。
3、到現在Go的開發已經是完全開放的,并且擁有一個活躍的社區。
1、編譯vimgdb
下載vimgdb73和vim73
mkdir -p ./tmp
cd tmp
tar zxvf ../vim-7.3.tar.gz
unzip ../vimgdb-for-vim7.3-master.zip
mv vimgdb-for-vim7.3-master vimgdb-for-vim7.3
patch -p0 vimgdb-for-vim7.3/vim73.patch
cd vim73
安裝依賴
sudo apt-get install build-essential
sudo apt-get build-dep vim-gtk
sudo apt-get install libncurses5-dev
安裝
// 這里直接執行make的操作
make
sudo make install
安裝vimgdb runtime
cd ../vimgdb-for-vim7.3
cp vimgdb_runtime ~/.vim/bundle
打開vim
:helptags ~/.vim/bundle/vimgdb_runtime/doc " 生成doc文件
添加配置.vimrc
" vimgdb插件
run macros/gdb_mappings.vim
在vim中執行gdb時,報 “Unable to read from GDB pseudo tty” 的錯誤,因為沒有安裝 gdb ,所以安裝gdb
sudo apt-get install gdb
2、安裝vundle
set up vundle
$ git clone ~/.vim/bundle/vundle
Configure Plugins
在.vimrc文件的開頭添加下面的內容,有些不是必須的,可以注掉
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from
Plugin 'L9'
Plugin 'FuzzyFinder'
" scripts not on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin ''
" ...
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" : PluginList - list configured plugins
" : PluginInstall(!) - install (update) plugins
" : PluginSearch(!) foo - search (or refresh cache first) for foo
" : PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
" Put your stuff after this line
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
3、官方vim-lang插件
Config vim file .vimrc,Add content bellow in bottom of the file
" 官方的插件
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to
" reload them.
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre Fmt
4、代碼補全的插件gocode
配置go的環境變量,比如我的配置,GOPATH變量是必須要配置的,PATH中必須把GOPATH的bin也添加進去,否則沒有自動提示,會提示找不到模式
export GOROOT=/usr/local/go
export GOPATH=/data/app/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Set up gocode
Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this:
go get -u github.com/nsf/gocode (-u flag for "update")
Configure vim in .vimrc file
Plugin 'nsf/gocode', {'rtp': 'vim/'}
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
寫一個helloword程序,輸入fmt后按C-xC-o如果能看到函數的聲明展示出來,說明安裝是正確的。
4、代碼跳轉提示godef
Set up godef
go get -v code.google.com/p/rog-go/exp/cmd/godef
go install -v code.google.com/p/rog-go/exp/cmd/godef
git clone ~/.vim/bundle/vim-godef
Configure vim in .vimrc file
Bundle 'dgryski/vim-godef'
Install Plugins
Launch vim and run
: PluginInstall
vim +PluginInstall +qall
5、代碼結構提示gotags
Set up gotags
go get -u github.com/jstemmer/gotags
Put the following configuration in your vimrc:
Bundle 'majutsushi/tagbar'
nmap :TagbarToggle
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
命令模式下按在右邊就會顯示當前文件下的函數名,結構體名等等,光標放到相應的tag上,按回車可以快速跳到程序中的相應位置。
再次按會關閉tag窗口。
PS:本地的.vimrc的配置
" 插件管理器 vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
" Plugin 'tpope/vim-fugitive'
" Plugin 'Lokaltog/vim-easymotion'
" Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from
" Plugin 'L9'
" Plugin 'FuzzyFinder'
" scripts not on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin ''
" ...
"
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
" filetype plugin on
"
" Brief help
" : PluginList - list configured plugins
" : PluginInstall(!) - install (update) plugins
" : PluginSearch(!) foo - search (or refresh cache first) for foo
" : PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
" Put your stuff after this line
syntax on
" ********************************************************************
" 這里省略了其它不相關的插件
" vimgdb插件
run macros/gdb_mappings.vim
" 官方的插件
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to
" reload them.
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
autocmd FileType go autocmd BufWritePre buffer Fmt
" 代碼補全的插件
Bundle 'Blackrush/vim-gocode'
" 代碼跳轉提示
Bundle 'dgryski/vim-godef'
" 代碼結構提示
Bundle 'majutsushi/tagbar'
nmap F8 :TagbarToggleCR
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
1. 部署簡單
Go
編譯生成的是一個靜態可執行文件,除了glibc外沒有其他外部依賴。這讓部署變得異常方便:目標機器上只需要一個基礎的系統和必要的管理、監控工具,完全不需要操心應用所需的各種包、庫的依賴關系,大大減輕了維護的負擔。
2. 并發性好
Goroutine和channel使得編寫高并發的服務端軟件變得相當容易,很多情況下完全不需要考慮鎖機制以及由此帶來的各種問題。單個Go應用也能有效的利用多個CPU核,并行執行的性能好。
3. 良好的語言設計
從學術的角度講Go語言其實非常平庸,不支持許多高級的語言特性;但從工程的角度講,Go的設計是非常優秀的:規范足夠簡單靈活,有其他語言基礎的程序員都能迅速上手。更重要的是
Go 自帶完善的工具鏈,大大提高了團隊協作的一致性。
4. 執行性能好
雖然不如 C 和 Java,但相比于其他編程語言,其執行性能還是很好的,適合編寫一些瓶頸業務,內存占用也非常省。
1、學習曲線
它包含了類C語法、GC內置和工程工具。這一點非常重要,因為Go語言容易學習,所以一個普通的大學生花一個星期就能寫出來可以上手的、高性能的應用。在國內大家都追求快,這也是為什么國內Go流行的原因之一。
2、效率
Go擁有接近C的運行效率和接近PHP的開發效率,這就很有利的支撐了上面大家追求快速的需求。
3、出身名門、血統純正
之所以說Go語言出身名門,是因為我們知道Go語言出自Google公司,這個公司在業界的知名度和實力自然不用多說。Google公司聚集了一批牛人,在各種編程語言稱雄爭霸的局面下推出新的編程語言,自然有它的戰略考慮。而且從Go語言的發展態勢來看,Google對它這個新的寵兒還是很看重的,Go自然有一個良好的發展前途。我們看看Go語言的主要創造者,血統純正這點就可見端倪了。
4、組合的思想、無侵入式的接口
Go語言可以說是開發效率和運行效率二者的完美融合,天生的并發編程支持。Go語言支持當前所有的編程范式,包括過程式編程、面向對象編程以及函數式編程。
5、強大的標準庫
這包括互聯網應用、系統編程和網絡編程。Go里面的標準庫基本上已經是非常穩定,特別是我這里提到的三個,網絡層、系統層的庫非常實用。
6、部署方便
我相信這一點是很多人選擇Go的最大理由,因為部署太方便,所以現在也有很多人用Go開發運維程序。
7、簡單的并發
它包含降低心智的并發和簡易的數據同步,我覺得這是Go最大的特色。之所以寫正確的并發、容錯和可擴展的程序如此之難,是因為我們用了錯誤的工具和錯誤的抽象,Go可以說這一塊做的相當簡單。
8、穩定性
Go擁有強大的編譯檢查、嚴格的編碼規范和完整的軟件生命周期工具,具有很強的穩定性,穩定壓倒一切。那么為什么Go相比于其他程序會更穩定呢?這是因為Go提供了軟件生命周期的各個環節的工具,如go
tool、gofmt、go test。
Go語言自亮相以來并沒有展示一個明確的方向,Google員工將Go語言稱為一個“試驗性語言”,稱其試圖融合Python等動態語言的開發速度和C或C++等編譯語言的性能和安全。一位Go語言的支持者概括而言Go語言如下:簡單、快速、安全、并發、快樂編程、開源;但Go語言缺乏方向以及其“集大成者”的嘗試很容易會導致其學貓不成學狗也不成,淪為四不像。盡管如此,編者仍然覺得Go語言有相當大的潛力:很多開發者對它感興趣——不僅它的最初設計者陣容強大,而且在參與修改源代碼的人群中也不乏大牛級人物。這很有可能幫助Go語言找到適合自己的方向,開拓系統編程的新方向。
文章標題:go語言缺少集 go語言為什么沒有類
文章網址:http://www.yijiale78.com/article10/doddedo.html
成都網站建設公司_創新互聯,為您提供域名注冊、移動網站建設、營銷型網站建設、標簽優化、企業建站、網站維護
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯