百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 编程字典 > 正文

golang实战-1:搭建vim-go开发环境

toyiye 2024-06-24 19:22 12 浏览 0 评论

目录

(1).基本概念与注意事项

(2).升级vim8

(3).Vundle安装

a.下载Vundle

b.插件配置

c.文件解析

d.安装Vundle插件

(4).配置高亮

(5).安装YouCompleteMe'插件

(6).安装go插件

1.安装go环境

2.安装vim-go插件

3.修改go.vim

(7).安装树形目录插件

(8).vim常用命令


(1).基本概念


Vundle: 管理vim插件

YouCompleteMe: 自动补齐插件


本文实操环境:

LSB Version: :core-4.1-amd64:core-4.1-noarch

Distributor ID: CentOS

Description: CentOS Linux release 7.3.1611 (Core)

Release: 7.3.1611

Codename: Core


整个环境很难装,会遇到很多问题,不同os不同基础组件版本的不同都会带来各种各样的问题,本文仅保证上述OS下的顺利部署(其实你可能还会遇到一些问题);其他版本下的安装大同小异,但是会出现各种各样问题。


Python版本:3.6.8,pthon3的版本差异也会导致出现问题;

YouCompleteMe版本:master最新;

Vim版本:8.1-2171

go版本:version go1.13.3 linux/amd64


完成安装后最好使用xshell进行开发,SecureCRT下开发go有可能出现乱码(即使你把所有相关编码都改成UTF8)。


(2) .升级vim8


不升级有可能报版本问题:

YouCompleteMe unavailable: requires Vim 7.4.1578+。

vim-go requires at least Vim 8.0.1453 or Neovim 0.3.2, but you're using an older version。

而且很多插件现在对vim7支持不一定好(也可以理解)。

升级到vim的最新版本。


注意不要使用python3.8等最新版本(我采坑了,手贱),python特么又要变API,vim目前还不支持新版本的python,我使用3.6.8。


1.安装依赖


yum install -y cmake gcc-c++ make ncurses-devel wget libzip bzip2 git zlib-devel


zlib-devel作用:

如果不安装,编译python3.6.8时会报错:

zipimport.ZipImportError: can't decompress data; zlib not available


安装python3.6.8:

https://www.python.org/downloads/release/python-368/

wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz

解压:tar -xvf Python-3.6.8.tar.xz

建立空文件夹,放置python安装程序: mkdir /usr/local/python3

执行: ./configure prefix=/usr/local/python3 --enable-shared --with-openssl=/usr/local/ssl

执行: make && make install

建立软连接:将python3都指向python3.6.8

ln -s /usr/local/python3/bin/python3.6 /usr/local/bin/python3

ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3

升级python3后有可能yum不能使用,因为yum默认使用python2,需要修改/usr/bin/yum,第一行改为:#!/usr/bin/python2.x


执行python3时有可能报错:

error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

需要拷贝源文件:

cp libpython3.6m.so.1.0 /usr/lib64

再执行python3则OK。


注意:

1. YouCompleteMe,需要python3,以动态连接库的方式去编译,即python3在编译的时候需要加上:--enable-shared,同时在python3.6.5之后在使用pip的时候,需要ssl,所以也需要指定:--with-openssl=/usr/local/ssl,/usr/local/ssl是openssl的安装路径,同时python3,需要openssl的版本在1.0.2或是1.1.1之上,所以有可能需要升级系统的

2. 因为后续还要安装YouCompleteMe插件,YCM插件需要vim支持python2,所以这里python2和python3都有配置。试过只配置python3不配置python2支持会导致插件安装成功后打开.py文件vim就会报错: Vim: Caught deadly signal SEGV Segmentation fault。

3. 指定正确的路径很重要。如果您使用的是Python,则您的config目录可能具有特定于计算机的名称(例如config-3.6m-x86_64-linux-gnu),找到自己的config路径并相应的更改configure里的python路径


2.安装vim8


安装依赖:yum -y install python-devel


wget https://github.com/vim/vim/archive/v8.1.2171.tar.gz

解压后进入目录:

make clean


为了避免YouCompleteMed的最终错误:

unavailable: /usr/local/python3/lib/python3.6/lib-dynload/_socket.cpython-3。6m-x86_64-linux-gnu.so: undefined symbol: PyExc_OSError

需要加编译参数:

--with-python3-config-dir=/usr/local/python3/lib/python3.6/config-3.6m-x86_64-linux-gnu


python2,python3都支持

./configure -enable-pythoninterp --with-python-command=/usr/bin/python --with-python-config-dir=/usr/lib64/python2.7/config --enable-python3interp=yes --with-python3-command=/usr/local/bin/python3 --with-python3-config-dir=/usr/local/python3/lib/python3.6/config-3.6m-x86_64-linux-gnu --with-features=huge --enable-fail-if-missing --enable-cscope --enable-multibyte --enable-fontset --prefix=/usr/local/vim8


make

make install


如果安装时出现错误,使用make distclean清除。


rm /usr/bin/vim

ln -s /usr/local/vim8/bin/vim /usr/bin/vim


完成升级,执行vim --version验证:


(3).Vundle安装


参考官方:https://github.com/VundleVim/Vundle.vim#about


a.下载Vundle


将Vundle下载到本地,后面下载的插件也将会下载到~/.vim/bundle路径下。

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim


b.插件配置


将如下的内容粘贴到~/.vimrc的顶部,前提是,你本身.vimrc里一开始没有什么其他内容。如果文件有内容,需要根据自身情况修改。


set nocompatible " be iMproved, required

filetype off " required


" set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" alternatively, pass a path where Vundle should install plugins

"call vundle#begin('~/some/path/here')


" let Vundle manage Vundle, required

Plugin 'VundleVim/Vundle.vim'


" The following are examples of different formats supported.

" Keep Plugin commands between vundle#begin/end.

" plugin on GitHub repo

" Plugin 'tpope/vim-fugitive'

" plugin from http://vim-scripts.org/vim/scripts.html

" Plugin 'L9'

" Git plugin not hosted 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 'file:///home/gmarik/path/to/plugin'

" 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/'}

" Install L9 and avoid a Naming conflict if you've already installed a

" different version somewhere else.

" Plugin 'ascenator/L9', {'name': 'newL9'}


" All of your Plugins must be added before the following line

call vundle#end() " required

filetype plugin indent on " required

" To ignore plugin indent changes, instead use:

"filetype plugin on

"

" Brief help

" :PluginList - lists configured plugins

" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate

" :PluginSearch foo - searches for foo; append `!` to refresh local cache

" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal

"

" see :h vundle for more details or wiki for FAQ

" Put your non-Plugin stuff after this line


如果.vimrc不存在,将上述段落拷贝后可能由于编码报错,需要如下处理:

yum install -y dos2unix

dos2unix ~/.vimrc


c.文件解析


c.1.set nocompatible作用


set compatible 就是让 vim 关闭所有扩展的功能,尽量模拟 vi 的行为。

但这样就不应用 vim 的很多强大功能,所以一般没有什么特殊需要的话(比如执行很老的 vi 脚本),都要在 vim 的配置开始,写上 set nocompatible,关闭兼容模式。由于这个选项是最最基础的选项,会连带很多其它选项发生变动(称作副作用),所以它必需是第一个设定的选项。


c.2.filetype off作用


执行:filetype可以查看Vim的文件类型检测功能是否已打开,默认你会看到:detection:ON plugin:OFF indent:OFF。


detection:默认情况vim会对文件自动检测文件类型,也就是你看到的'detection:ON',同样你可以手动关闭:filetype off。 可以用:set filetype查看当前文件是什么类型了。 类似file.txt文件的filetype设置为python,那么就和普通的python文件一样的显示效果了:set filetype=python。

另一种方式就是在文件内容中指定,Vim会从文件的头几行自动扫描文件是否有声明文件的类型的代码,如在文件的行首加入# vim: filetype=python,Java文件变通的做法/* vim: filetype=java */,总之就是把这行当作注释,以致于不影响文件的编译,这样Vim不通过文件名也能检测出文件是什么类型了。


plugin:如果plugin状态时ON,那么就会在Vim的运行时环境目录下加载该类型相关的插件。比如为了让Vim更好的支持Python编程,你就需要下载一些Python相关的插件,此时就必须设置plugin为ON插件才会生效,具体设置方法就是:filetype plugin on


indent:不同类型文件有不同的方式,比如Python就要求使用4个空格作为缩进,而c使用两个tab作为缩进,那么indent就可以为不同文件类型选择合适的缩进方式了。你可以在Vim的安装目录的indent目录下看到定义了很多缩进相关的脚本。具体设置方法:filetype indent on。


以上三个参数,可以写成一行filetype plugin indent on设置在_vimrc文件中。


c.3.set rtp+=~/.vim/bundle/Vundle.vim作用:


设置包括vundle和初始化相关的runtime path


c.4.call vundle#begin()与call vundle#end()作用


安装的Plugin都在两者之间配置。


d.安装Vundle插件


执行vim命令,然后输入::PluginInstall



(4).配置高亮


vim在粘贴内容的时候,如果遇到以#开始的注释行,会自动将后续的所有行进行注释。

取消这个功能也很简单,只需要在根目录下编辑.vimrc文件(如果没有,就创建该文件),在其中添加下面的内容:

set paste


将如下内容复制到文件末尾:~/.vimrc


"ctags

set tags=tags;/


set wrapscan "启用循环查找方式

set guifont=Monaco:h10 " 字体 && 字号

set expandtab " 设置tab键换空格

set tabstop=4 " 设置tab键的宽度

set shiftwidth=4 " 换行时行间交错使用4个空格

set autoindent " 自动对齐

set backspace=2 " 设置退格键可用

set cindent shiftwidth=4 " 自动缩进4空格

set smartindent " 智能自动缩进

set ai! " 设置自动缩进

"set nu! " 显示行号

"set showmatch " 显示括号配对情况

"set mouse=a " 启用鼠标

"set ruler " 右下角显示光标位置的状态行

set incsearch " 查找book时,当输入/b时会自动找到

set hlsearch " 开启高亮显示结果

set incsearch " 开启实时搜索功能

set nowrapscan " 搜索到文件两端时不重新搜索

set nocompatible " 关闭兼容模式

set vb t_vb= " 关闭提示音

"set cursorline " 突出显示当前行

set hidden " 允许在有未保存的修改时切换缓冲区


syntax enable " 打开语法高亮

syntax on " 开启文件类型侦测

filetype indent on " 针对不同的文件类型采用不同的缩进格式

filetype plugin on " 针对不同的文件类型加载对应的插件

filetype plugin indent on " 启用自动补全


set writebackup " 设置无备份文件

set nobackup

"set autochdir " 设定文件浏览器目录为当前目录

"set nowrap " 设置不自动换行

"set foldmethod=syntax " 选择代码折叠类型

"set foldlevel=100 " 禁止自动折叠


set laststatus=2 " 开启状态栏信息

set cmdheight=2 " 命令行的高度,默认为1,这里设为2


" 每行超过80个的字符用下划线标示

au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.erb,*.hs,*.vim 2match Underlined /.\%81v/


" 设置编码

set fenc=utf-8

set encoding=utf-8

"set fileencodings=utf-8,gbk,cp936,latin-1

set fileencodings=utf-8

" 解决菜单乱码

source $VIMRUNTIME/delmenu.vim

source $VIMRUNTIME/menu.vim

" 解决consle输出乱码

language messages zh_CN.utf-8


" For Haskell

:let hs_highlight_delimiters=1 " 高亮定界符

:let hs_highlight_boolean=1 " 把True和False识别为关键字

:let hs_highlight_types=1 " 把基本类型的名字识别为关键字

:let hs_highlight_more_types=1 " 把更多常用类型识别为关键字

:let hs_highlight_debug=1 " 高亮调试函数的名字

:let hs_allow_hash_operator=1 " 阻止把#高亮为错误


"只有在是PHP文件时,才启用PHP补全

au FileType php call AddPHPFuncList()

function AddPHPFuncList()

set dictionary-=/home/feiyan/tools/vim/funclist.txt dictionary+=/home/feiyan/tools/vim/funclist.txt

set complete-=k complete+=k

endfunction


" ======= 恢复上次文件打开位置 ======= "

set viminfo='10,\"100,:20,%,n~/.viminfo

au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("#34;)|exe("norm'\"")|else|exe "norm #34;|endif|endif


set t_ti= t_te=

set hlsearch

if has("autocmd")

au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("#34;) | exe "normal! g'\"" | endif

endif


(5).安装YouCompleteMe'插件


先安装依赖:

yum -y install cmake centos-release-scl devtoolset-6 scl-utils scl-utils-build scl enable devtoolset-6 bash


在 vim 的配置文件 ~/.vimrc 中添加一行(在call vundle#begin() 和 call vundle#end() 之间)

call vundle#begin()

. . .

Plugin 'Valloric/YouCompleteMe'

. . .

call vundle#end()


vim

执行:

:PluginInstall


安装YCM如果出现:

The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library not detected; you need to compile YCM before using it. Follow the instructions in the documentation.

需要顺次执行:

cd ~/.vim/bundle/YouCompleteMe

git submodule update --init --recursive

python3 install.py --clang-completer

然后打开vim执行:

:YcmRestartServer (这步很重要,我老忘记)


安装YCM如果出现:

YouCompleteMe unavailable no module named frozendict或者 YouCompleteMe unavailable no module named future

原因就是你或者没用Vundle安装,或者Vundle由于网速太慢下载到一半不能把安装依赖包完全下载下来

解决方案:

进入到YouCompleteMe目录(/root/.vim/bundle/YouCompleteMe),在terminal窗口敲入git submodule update --init --recursive

然后顺次执行:

cd ~/.vim/bundle/YouCompleteMe

python3 install.py --clang-completer


至此完成ycm插件的安装,可以写一个python看到效果:

上图是笔者写的一个rocketmq-exporter,可以下载体验vim,位于:

https://github.com/hepyu/hpy-rocketmq-exporter/tree/master/src


也可以手动安装看进度:

git clone --recursive https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

然后:

cd ~/.vim/bundle/YouCompleteMe

python3 install.py --clang-completer

至此完成安装。


(6).安装go插件


我使用的go版本是:

go version go1.13.3 linux/amd64


1.安装go环境


进入下载页面:

https://golang.org/dl/


下载最新版本:

wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz


解压:

tar -C /usr/local -xzf go1.13.3.linux-amd64.tar.gz

在/etc/profile中添加环境变量:

export PATH=$PATH:/usr/local/go/bin

然后让其生效:

source /etc/profile


验证go是否安装成功:

go version

go version go1.13.3 linux/amd64


2.修改~/.vimrc


在 vim 的配置文件 ~/.vimrc 中添加一行(在call vundle#begin() 和 call vundle#end() 之间)

call vundle#begin()

. . .

Plugin 'fatih/vim-go'

. . .

call vundle#end()


vim

执行:

:PluginInstall


3.安装go插件


由于vim-go要下载很多golang的命令,有些需要翻墙,所以我们需要把翻墙的插件换成github上的替代者。


文件位于:~/.vim/bundle/vim-go/plugin/go.vim


let s:packages = {

\ 'asmfmt': ['github.com/klauspost/asmfmt/cmd/asmfmt'],

\ 'dlv': ['github.com/go-delve/delve/cmd/dlv'],

\ 'errcheck': ['github.com/kisielk/errcheck'],

\ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],

\ 'gocode': ['github.com/mdempsky/gocode', {'windows': ['-ldflags', '-H=windowsgui']}],

\ 'gocode-gomod': ['github.com/stamblerre/gocode'],

\ 'godef': ['github.com/rogpeppe/godef'],

\ 'gogetdoc': ['github.com/zmb3/gogetdoc'],

\ 'goimports': ['golang.org/x/tools/cmd/goimports'],

\ 'golint': ['golang.org/x/lint/golint'],

\ 'gopls': ['golang.org/x/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],

\ 'golangci-lint': ['github.com/golangci/golangci-lint/cmd/golangci-lint'],

\ 'gomodifytags': ['github.com/fatih/gomodifytags'],

\ 'gorename': ['golang.org/x/tools/cmd/gorename'],

\ 'gotags': ['github.com/jstemmer/gotags'],

\ 'guru': ['golang.org/x/tools/cmd/guru'],

\ 'impl': ['github.com/josharian/impl'],

\ 'keyify': ['honnef.co/go/tools/cmd/keyify'],

\ 'motion': ['github.com/fatih/motion'],

\ 'iferr': ['github.com/koron/iferr'],

\ }


可以看到有如下插件需要翻墙:

'goimports': ['golang.org/x/tools/cmd/goimports'],

'golint': ['golang.org/x/lint/golint'],

'gopls': ['golang.org/x/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],

'gorename': ['golang.org/x/tools/cmd/gorename'],

'guru': ['golang.org/x/tools/cmd/guru'],


完成包下载需要结合下述三种方法一同使用。


方法一:

由于存在翻墙问题,设置goproxy:

遇到网络问题:这样解决,可以把下述配置加入/etc/profile,然后soruce /etc/profile使其生效

# Enable the go modules feature

export GO111MODULE=on

# Set the GOPROXY environment variable

export GOPROXY=https://goproxy.io

然后任意打开一个.go的文件,然后运行 :GoInstallBinaries自动安装插件。


方法二:可以直接执行:

go get github.com/golang/tools/cmd/goimports

go get github.com/golang/tools/cmd/guru

go get github.com/golang/tools/cmd/gorename


方法三:

先将依赖的项目都git clone到本地。

cd ~/go/src

git clone https://github.com/golang/tools golang.org/x/tools

然后~/go/src下执行:

go install golang.org/x/tools/cmd/goimports

go install golang.org/x/tools/cmd/guru

go install golang.org/x/tools/cmd/gorename


golint需要修改go.vim:

'golint': ['github.com/golang/lint/golint'],

'gopls': ['github.com/golang/tools/gopls@latest', {}, {'after': function('go#lsp#Restart', [])}],


golint在github上是golang/lint项目下的目录,所以要在~/go/src下执行:

git clone https://github.com/golang/lint.git golang.org/x/lint

执行:

go install golang.org/x/lint


在~/go/src下执行命令下载gopls:

git clone https://github.com/golang/tools/gopls golang.org/x/tools/gopls

gopls本身需要翻墙,另外还依赖很多别的项目,需要:

git clone https://github.com/sergi/go-diff.git sergi/go-diff

git clone https://github.com/BurntSushi/toml BurntSushi/toml

git clone https://github.com/golang/sync.git golang.org/x/sync

git clone https://github.com/golang/xerrors.git golang.org/x/xerrors

git clone https://github.com/golang/tools golang.org/x/tools

最后执行:

go install golang.org/x/tools/gopls

完成gopls


其余插件类似这样处理,或者:

任意打开一个.go的文件,然后运行 :GoInstallBinaries自动安装插件。

效果:

注意上图pakcage是乱码,crt的问题,换成xshell就OK了:

注意最后一行表示成功:


(7).安装树形目录插件


vim ~/.vimrc,增加:


call vundle#begin()

Plugin 'scrooloose/nerdtree'

call vundle#end()


然后打开vim,执行命令:PluginInstall安装插件。


安装好后,命令行中输入vim,打开vim后,在vim中输入:NERDTree,你就可以看到NERDTree的效果了。


为方便起见,直接 vim ~/.vimrc 然后添加:


"F2开启和关闭树"

map <F2> :NERDTreeToggle<CR>

let NERDTreeChDirMode=1

"显示书签"

let NERDTreeShowBookmarks=1

"设置忽略文件类型"

let NERDTreeIgnore=['\~#39;, '\.pyc#39;, '\.swp#39;]

"窗口大小"

let NERDTreeWinSize=25


这样打开vim后,只要按键盘上的F2就可以显示和隐藏NERDTree的文件浏览了。


如何修改快捷键命令,参考官方:

https://github.com/ycm-core/YouCompleteMe#the-gycm_key_invoke_completion-option

比如mac笔记本默认是ctrl+space与mac os冲突,我们需要修改:

let g:ycm_key_invoke_completion = '<c-n>'

放到~/.vimrc下即可,快捷键:ctrl+n。


常用快捷命令:

#快捷方式 切换工作台和目录

ctrl + w + h 光标 focus 左侧树形目录

ctrl + w + l 光标 focus 右侧文件显示窗口

ctrl + w + w 光标自动在左右侧窗口切换

ctrl + w + r 移动当前窗口的布局位置

o 在已有窗口中打开文件、目录或书签,并跳到该窗口

go 在已有窗口 中打开文件、目录或书签,但不跳到该窗口

t 在新 Tab 中打开选中文件/书签,并跳到新 Tab

T 在新 Tab 中打开选中文件/书签,但不跳到新 Tab

i split 一个新窗口打开选中文件,并跳到该窗口

gi split 一个新窗口打开选中文件,但不跳到该窗口

s vsplit 一个新窗口打开选中文件,并跳到该窗口

gs vsplit 一个新 窗口打开选中文件,但不跳到该窗口

! 执行当前文件

O 递归打开选中 结点下的所有目录

x 合拢选中结点的父目录

X 递归 合拢选中结点下的所有目录

e Edit the current dif

双击 相当于 NERDTree-o

中键 对文件相当于 NERDTree-i,对目录相当于 NERDTree-e

D 删除当前书签

P 跳到根结点

p 跳到父结点

K 跳到当前目录下同级的第一个结点

J 跳到当前目录下同级的最后一个结点

k 跳到当前目录下同级的前一个结点

j 跳到当前目录下同级的后一个结点

C 将选中目录或选中文件的父目录设为根结点

u 将当前根结点的父目录设为根目录,并变成合拢原根结点

U 将当前根结点的父目录设为根目录,但保持展开原根结点

r 递归刷新选中目录

R 递归刷新根结点

m 显示文件系统菜单cd 将 CWD 设为选中目录

I 切换是否显示隐藏文件

f 切换是否使用文件过滤器

F 切换是否显示文件

B 切换是否显示书签

q 关闭 NerdTree 窗口

? 切换是否显示 Quick Help


(8).vim常用命令


:PluginList - 枚举已安装的插件列表

:PluginInstall - 安装插件或者后面加上'!'更新

:PluginUpdate - 更新插件 同 :PluginInstall!

:PluginSearch foo - 查找插件。例如查找名称为foo的插件。或者后面加'!'更新本地缓存

:PluginClean - 清理无用插件或者后面加'!'自动清理


相关推荐

为何越来越多的编程语言使用JSON(为什么编程)

JSON是JavascriptObjectNotation的缩写,意思是Javascript对象表示法,是一种易于人类阅读和对编程友好的文本数据传递方法,是JavaScript语言规范定义的一个子...

何时在数据库中使用 JSON(数据库用json格式存储)

在本文中,您将了解何时应考虑将JSON数据类型添加到表中以及何时应避免使用它们。每天?分享?最新?软件?开发?,Devops,敏捷?,测试?以及?项目?管理?最新?,最热门?的?文章?,每天?花?...

MySQL 从零开始:05 数据类型(mysql数据类型有哪些,并举例)

前面的讲解中已经接触到了表的创建,表的创建是对字段的声明,比如:上述语句声明了字段的名称、类型、所占空间、默认值和是否可以为空等信息。其中的int、varchar、char和decimal都...

JSON对象花样进阶(json格式对象)

一、引言在现代Web开发中,JSON(JavaScriptObjectNotation)已经成为数据交换的标准格式。无论是从前端向后端发送数据,还是从后端接收数据,JSON都是不可或缺的一部分。...

深入理解 JSON 和 Form-data(json和formdata提交区别)

在讨论现代网络开发与API设计的语境下,理解客户端和服务器间如何有效且可靠地交换数据变得尤为关键。这里,特别值得关注的是两种主流数据格式:...

JSON 语法(json 语法 priority)

JSON语法是JavaScript语法的子集。JSON语法规则JSON语法是JavaScript对象表示法语法的子集。数据在名称/值对中数据由逗号分隔花括号保存对象方括号保存数组JS...

JSON语法详解(json的语法规则)

JSON语法规则JSON语法是JavaScript对象表示法语法的子集。数据在名称/值对中数据由逗号分隔大括号保存对象中括号保存数组注意:json的key是字符串,且必须是双引号,不能是单引号...

MySQL JSON数据类型操作(mysql的json)

概述mysql自5.7.8版本开始,就支持了json结构的数据存储和查询,这表明了mysql也在不断的学习和增加nosql数据库的有点。但mysql毕竟是关系型数据库,在处理json这种非结构化的数据...

JSON的数据模式(json数据格式示例)

像XML模式一样,JSON数据格式也有Schema,这是一个基于JSON格式的规范。JSON模式也以JSON格式编写。它用于验证JSON数据。JSON模式示例以下代码显示了基本的JSON模式。{"...

前端学习——JSON格式详解(后端json格式)

JSON(JavaScriptObjectNotation)是一种轻量级的数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。它基于JavaScriptProgrammingLa...

什么是 JSON:详解 JSON 及其优势(什么叫json)

现在程序员还有谁不知道JSON吗?无论对于前端还是后端,JSON都是一种常见的数据格式。那么JSON到底是什么呢?JSON的定义...

PostgreSQL JSON 类型:处理结构化数据

PostgreSQL提供JSON类型,以存储结构化数据。JSON是一种开放的数据格式,可用于存储各种类型的值。什么是JSON类型?JSON类型表示JSON(JavaScriptO...

JavaScript:JSON、三种包装类(javascript 包)

JOSN:我们希望可以将一个对象在不同的语言中进行传递,以达到通信的目的,最佳方式就是将一个对象转换为字符串的形式JSON(JavaScriptObjectNotation)-JS的对象表示法...

Python数据分析 只要1分钟 教你玩转JSON 全程干货

Json简介:Json,全名JavaScriptObjectNotation,JSON(JavaScriptObjectNotation(记号、标记))是一种轻量级的数据交换格式。它基于J...

比较一下JSON与XML两种数据格式?(json和xml哪个好)

JSON(JavaScriptObjectNotation)和XML(eXtensibleMarkupLanguage)是在日常开发中比较常用的两种数据格式,它们主要的作用就是用来进行数据的传...

取消回复欢迎 发表评论:

请填写验证码