Golang ETCD包的安装使用 golang安装etcd第三方库clientv3 报错 解决
ETCD
官网
https://etcd.io/docs/v3.5/install/
视频地址
https://www.bilibili.com/video/BV19J41147uT?p=7
课件资料
https://www.liwenzhou.com/posts/Go/go_etcd/
ETCD
日志收集项目
为什么要自己写不用ELK?
ELK: 部署的时候麻烦每一个filebeat都需要配置一个配置文件
使用etcd来管理被收集的日志项。
项目的架构
上节课项目进度
- kafka:消息队列
- tailf:从文件里读日志
- go-ini:解析配置文件
etcd介绍
详见群文件:etcd.pdf
http://www.5lmh.com/数据库操作/go操作etcd/操作etcd.html
安装etcd
详见:https://docs.qq.com/doc/DTndrQXdXYUxUU09O
windows安装
https://github.com/etcd-io/etcd/releases
下载软件:
解压后:etcd.exe就是启动程序
Ubuntu(linux系统)安装etcd
方法一:
下载:etcd-v3.3.18-linux-amd64
解压文件即可使用,无需安装
方法二:
https://github.com/etcd-io/etcd/releases/tag/v3.4.14
新建 install_etcd.sh
ETCD_VER=v3.4.14
# choose either URL
GOOGLE_URL=https://storage.googleapis.com/etcd
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GITHUB_URL}
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
#curl -L https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
#rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
mv /tmp/etcd-download-test /opt/etcd-v3.4.14-linux-amd64
cd /opt/etcd-v3.4.14-linux-amd64
/opt/etcd-v3.4.14-linux-amd64/etcd --version
/opt/etcd-v3.4.14-linux-amd64/etcdctl version
# start a local etcd server
/opt/etcd-v3.4.14-linux-amd64/etcd
# write,read to etcd
/opt/etcd-v3.4.14-linux-amd64/etcdctl --endpoints=localhost:2379 put foo bar
/opt/etcd-v3.4.14-linux-amd64/etcdctl --endpoints=localhost:2379 get foo
#加入系统环境变量
ln -s /opt/etcd-v3.4.14-linux-amd64/etcdctl /usr/bin/etcdctl
命令行操作etcd
注意一定要使用V3版本的API
启动服务端
在命令行中
进入解压出来的目录中/opt/etcd-v3.3.18-linux-amd64
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# su root //切换到root账号
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# ./etcd //启动服务端
2020-05-19 07:14:33.832992 I | etcdmain: etcd Version: 3.3.18
2020-05-19 07:14:33.833045 I | etcdmain: Git SHA: 3c8740a79
2020-05-19 07:14:33.833054 I | etcdmain: Go Version: go1.12.9
2020-05-19 07:14:33.833063 I | etcdmain: Go OS/Arch: linux/amd64
2020-05-19 07:14:33.833072 I | etcdmain: setting maximum number of CPUs to 4, total number of available CPUs is 4
2020-05-19 07:14:33.833085 W | etcdmain: no data-dir provided, using default data-dir ./default.etcd
2020-05-19 07:14:33.833443 N | etcdmain: the server is already initialized as member before, starting as etcd member...
2020-05-19 07:14:33.836644 I | embed: listening for peers on http://localhost:2380
2020-05-19 07:14:33.836736 I | embed: listening for client requests on localhost:2379
2020-05-19 07:14:33.849127 I | etcdserver: name = default
2020-05-19 07:14:33.849150 I | etcdserver: data dir = default.etcd
2020-05-19 07:14:33.849165 I | etcdserver: member dir = default.etcd/member
2020-05-19 07:14:33.849174 I | etcdserver: heartbeat = 100ms
2020-05-19 07:14:33.849184 I | etcdserver: election = 1000ms
2020-05-19 07:14:33.849194 I | etcdserver: snapshot count = 100000
2020-05-19 07:14:33.849228 I | etcdserver: advertise client URLs = http://localhost:2379
2020-05-19 07:14:33.851066 I | etcdserver: restarting member 8e9e05c52164694d in cluster cdf818194e3a8c32 at commit index 8
2020-05-19 07:14:33.851102 I | raft: 8e9e05c52164694d became follower at term 2
2020-05-19 07:14:33.851117 I | raft: newRaft 8e9e05c52164694d [peers: [], term: 2, commit: 8, applied: 0, lastindex: 8, lastterm: 2]
2020-05-19 07:14:33.867515 W | auth: simple token is not cryptographically signed
2020-05-19 07:14:33.871849 I | etcdserver: starting server... [version: 3.3.18, cluster version: to_be_decided]
2020-05-19 07:14:33.878161 I | etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32
2020-05-19 07:14:33.878282 N | etcdserver/membership: set the initial cluster version to 3.3
2020-05-19 07:14:33.878340 I | etcdserver/api: enabled capabilities for version 3.3
2020-05-19 07:14:35.352464 I | raft: 8e9e05c52164694d is starting a new election at term 2
2020-05-19 07:14:35.352492 I | raft: 8e9e05c52164694d became candidate at term 3
2020-05-19 07:14:35.352510 I | raft: 8e9e05c52164694d received MsgVoteResp from 8e9e05c52164694d at term 3
2020-05-19 07:14:35.352526 I | raft: 8e9e05c52164694d became leader at term 3
2020-05-19 07:14:35.352541 I | raft: raft.node: 8e9e05c52164694d elected leader 8e9e05c52164694d at term 3
2020-05-19 07:14:35.352898 I | etcdserver: published {Name:default ClientURLs:[http://localhost:2379]} to cluster cdf818194e3a8c32
2020-05-19 07:14:35.352917 I | embed: ready to serve client requests
2020-05-19 07:14:35.353073 E | etcdmain: forgot to set Type=notify in systemd service file?
2020-05-19 07:14:35.353526 N | embed: serving insecure client requests on 127.0.0.1:2379, this is strongly discouraged!
启动成功后,
编写后台启动服务角本
start.sh
#!/bin/bash
echo "删除etcd进程"
killall etcd
echo "启动etcd进程"
nohup ./etcd >> etcd.log 2>&1 & # 日志文件输出到/tmp/etcd.log目录
ps -aux | grep etcd
后台运行了,可以关闭黑窗口
root@haima-PC:/opt/etcd-v3.4.14-linux-amd64# ./start.sh
删除etcd进程
etcd: no process found
启动etcd进程
root 5746 0.0 0.1 10612352 18648 pts/2 Sl+ 12:22 0:00 ./etcd
root 5748 0.0 0.0 14540 932 pts/2 S+ 12:22 0:00 grep etcd
编写停止服务角本
stop.sh
#!/bin/bash
echo "删除etcd进程"
killall etcd
ps -aux | grep etcd
停止etcd服务
root@haima-PC:/opt/etcd-v3.4.14-linux-amd64# ./stop.sh
删除etcd进程
root 7233 0.0 0.0 14540 964 pts/2 S+ 12:23 0:00 grep etcd
客户端操作
再开启一个命令行窗口
先设置环境变量:
Windows执行:
SET ETCDCTL_API=3
Mac或者Linux 执行
export ETCDCTL_API=3
如果不设置上面的环境变量,会报下面的错误:
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# ./etcdctl --endpoints=http://127.0.0.1:2379 put name lisi
No help topic for 'put'
命令行操作:使用自带的etcdctl
命令操作
进入解压出来的/opt/etcd-v3.3.18-linux-amd64
目录下
PUT:
./etcdctl --endpoints=http://127.0.0.1:2379 put key value
GET:
./etcdctl --endpoints=http://127.0.0.1:2379 get key
DEL:
./etcdctl --endpoints=http://127.0.0.1:2379 del key
linux下操作,如果是windows版本的,使用./etcdctl.exe
haima@haima-PC:/opt/etcd-v3.3.18-linux-amd64$ su
密码:
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# ./etcdctl --endpoints=http://127.0.0.1:2379 put name lisi
No help topic for 'put'
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# export ETCDCTL_API=3
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# ./etcdctl --endpoints=http://127.0.0.1:2379 put name lisi
OK
root@haima-PC:/opt/etcd-v3.3.18-linux-amd64# ./etcdctl --endpoints=http://127.0.0.1:2379 get name
name
lisi
go操作etcd
go mod设置代理
SET GOPROXY=https://goproxy.cn // Windows
export GOPROXY=https://goproxy.cn // Mac&Linux
PUT/GET
新建 etcd_put/main.go
package main
import (
"context"
"fmt"
"go.etcd.io/etcd/clientv3"
"time"
)
// etcd client put/get demo
// use etcd/clientv3
func main() {
cli, err := clientv3.New(clientv3.Config{
Endpoints: []string{"127.0.0.1:2379"},
DialTimeout: 5 * time.Second,
})
if err != nil {
// handle error!
fmt.Printf("connect to etcd failed, err:%v\n", err)
return
}
fmt.Println("connect to etcd success")
defer cli.Close()
// put
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
//value := `[{"path":"c:/tmp/nginx.log","topic":"web.log"},{"path":"d:/xxx/redis.log","topic":"redis.log"}]`
value := `[{"path":"c:/tmp/nginx.log","topic":"web.log"},{"path":"d:/xxx/redis.log","topic":"redis.log"},{"path":"d:/xxx/mysql.log","topic":"mysql.log"}]`
_, err = cli.Put(ctx, "/logagent/collect_config", value)
//_, err = cli.Put(ctx, "baodelu", "dsb")
cancel()
if err != nil {
fmt.Printf("put to etcd failed, err:%v\n", err)
return
}
// get
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
resp, err := cli.Get(ctx, "/logagent/collect_config")
cancel()
if err != nil {
fmt.Printf("get from etcd failed, err:%v\n", err)
return
}
for _, ev := range resp.Kvs {
fmt.Printf("%s:%s\n", ev.Key, ev.Value)
}
}
先运行服务端,
再启动go代码
首次运行go mod报错
go mod init
go mod tidy
go: haimait/learn/etcd/etcd_put imports
go.etcd.io/etcd/clientv3 tested by
go.etcd.io/etcd/clientv3.test imports
github.com/coreos/etcd/auth imports
github.com/coreos/etcd/mvcc/backend imports
github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.4: parsing go.mod:
module declares its path as: go.etcd.io/bbolt
but was required as: github.com/coreos/bbolt
我的go版本是(go version 可以查看版本)
go version go1.14.2 linux/amd64
报错原因:
go.mod 中更改下 etcd 的版本号,估计是 etcd 版本用的 "google.golang.org/grpc/resolver"版本比较新;
解决方法:
在go.mod里写上
module haimait/learn/etcd/etcd_watch
go 1.14
require (
github.com/coreos/bbolt v1.3.3 // indirect
github.com/coreos/etcd v3.3.21+incompatible // indirect
go.etcd.io/etcd v3.3.13+incompatible
)
再次执行
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/etcd/etcd_put$ go mod tidy
go: finding module for package google.golang.org/grpc/keepalive
go: finding module for package golang.org/x/crypto/bcrypt
go: finding module for package google.golang.org/grpc/grpclog
go: finding module for package google.golang.org/grpc/health/grpc_health_v1
go: finding module for package google.golang.org/grpc/metadata
go: finding module for package google.golang.org/grpc/credentials
go: finding module for package google.golang.org/grpc/codes
go: finding module for package github.com/gogo/protobuf/gogoproto
go: finding module for package google.golang.org/grpc/peer
go: finding module for package github.com/dgrijalva/jwt-go
go: finding module for package github.com/coreos/pkg/capnslog
go: finding module for package github.com/prometheus/client_golang/prometheus/promhttp
go: finding module for package google.golang.org/genproto/googleapis/api/annotations
go: finding module for package google.golang.org/grpc/connectivity
go: finding module for package github.com/golang/protobuf/proto
go: finding module for package google.golang.org/grpc/resolver/dns
go: finding module for package google.golang.org/grpc/resolver
go: finding module for package github.com/json-iterator/go
go: finding module for package go.uber.org/zap/zapcore
go: finding module for package go.uber.org/zap
go: finding module for package golang.org/x/time/rate
go: finding module for package golang.org/x/net/trace
go: finding module for package github.com/xiang90/probing
go: finding module for package github.com/grpc-ecosystem/go-grpc-prometheus
go: finding module for package golang.org/x/net/context
go: finding module for package github.com/grpc-ecosystem/grpc-gateway/utilities
go: finding module for package github.com/coreos/go-semver/semver
go: finding module for package github.com/jonboulle/clockwork
go: finding module for package github.com/modern-go/reflect2
go: finding module for package sigs.k8s.io/yaml
go: finding module for package google.golang.org/grpc/resolver/passthrough
go: finding module for package github.com/soheilhy/cmux
go: finding module for package google.golang.org/grpc/balancer
go: finding module for package github.com/coreos/go-systemd/journal
go: finding module for package google.golang.org/grpc
go: finding module for package github.com/google/btree
go: finding module for package google.golang.org/grpc/health
go: finding module for package github.com/tmc/grpc-websocket-proxy/wsproxy
go: finding module for package github.com/dustin/go-humanize
go: finding module for package github.com/grpc-ecosystem/go-grpc-middleware
go: finding module for package github.com/prometheus/client_golang/prometheus
go: finding module for package github.com/prometheus/client_model/go
go: finding module for package github.com/gogo/protobuf/proto
go: finding module for package google.golang.org/grpc/status
go: finding module for package github.com/grpc-ecosystem/grpc-gateway/runtime
go: finding module for package golang.org/x/sys/unix
go: finding module for package go.etcd.io/bbolt
go: finding module for package google.golang.org/grpc/naming
go: finding module for package github.com/google/uuid
go: finding module for package github.com/golang/groupcache/lru
go: found google.golang.org/grpc in google.golang.org/grpc v1.29.1
go: found github.com/gogo/protobuf/gogoproto in github.com/gogo/protobuf v1.3.1
go: found github.com/golang/protobuf/proto in github.com/golang/protobuf v1.4.2
go: found google.golang.org/genproto/googleapis/api/annotations in google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587
go: found github.com/grpc-ecosystem/go-grpc-prometheus in github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
go: found github.com/prometheus/client_golang/prometheus/promhttp in github.com/prometheus/client_golang v1.6.0
go: found golang.org/x/crypto/bcrypt in golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
go: found github.com/coreos/pkg/capnslog in github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
go: found github.com/dgrijalva/jwt-go in github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: found github.com/google/uuid in github.com/google/uuid v1.1.1
go: found go.uber.org/zap in go.uber.org/zap v1.15.0
go: found github.com/soheilhy/cmux in github.com/soheilhy/cmux v0.1.4
go: found github.com/coreos/go-systemd/journal in github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: found github.com/coreos/go-semver/semver in github.com/coreos/go-semver v0.3.0
go: found github.com/json-iterator/go in github.com/json-iterator/go v1.1.9
go: found github.com/modern-go/reflect2 in github.com/modern-go/reflect2 v1.0.1
go: found github.com/grpc-ecosystem/grpc-gateway/runtime in github.com/grpc-ecosystem/grpc-gateway v1.14.5
go: found github.com/tmc/grpc-websocket-proxy/wsproxy in github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966
go: found golang.org/x/net/trace in golang.org/x/net v0.0.0-20200513185701-a91f0712d120
go: found sigs.k8s.io/yaml in sigs.k8s.io/yaml v1.2.0
go: found github.com/jonboulle/clockwork in github.com/jonboulle/clockwork v0.1.0
go: found github.com/dustin/go-humanize in github.com/dustin/go-humanize v1.0.0
go: found github.com/grpc-ecosystem/go-grpc-middleware in github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
go: found golang.org/x/time/rate in golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1
go: found github.com/xiang90/probing in github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
go: found golang.org/x/sys/unix in golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9
go: found github.com/google/btree in github.com/google/btree v1.0.0
go: found github.com/golang/groupcache/lru in github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
go: found go.etcd.io/bbolt in go.etcd.io/bbolt v1.3.4
go: found github.com/prometheus/client_model/go in github.com/prometheus/client_model v0.2.0
go: finding module for package github.com/gorilla/websocket
go: found github.com/gorilla/websocket in github.com/gorilla/websocket v1.4.2
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/etcd/etcd_put$ go run main.go
connect to etcd success
/logagent/collect_config:[{"path":"c:/tmp/nginx.log","topic":"web.log"},{"path":"d:/xxx/redis.log","topic":"redis.log"},{"path":"d:/xxx/mysql.log","topic":"mysql.log"}]
如果还是解决不了,请参考下面连接
https://my.oschina.net/u/2321997/blog/4258724/print
watch
非常重要
新建 etcd_watch/main.go
package main
import (
"context"
"fmt"
"go.etcd.io/etcd/clientv3"
"time"
)
// etcd watch
func main() {
cli, err := clientv3.New(clientv3.Config{
Endpoints: []string{"127.0.0.1:2379"},
DialTimeout: 5 * time.Second,
})
if err != nil {
// handle error!
fmt.Printf("connect to etcd failed, err:%v\n", err)
return
}
fmt.Println("connect to etcd success")
defer cli.Close()
// watch
// 派一个哨兵 一直监视着 /logagent/collect_config 这个key的变化(新增、修改、删除)
ch := cli.Watch(context.Background(), "/logagent/collect_config")
// 从通道尝试取值(监视的信息)
for wresp := range ch{
for _, evt := range wresp.Events{
fmt.Printf("Type:%v key:%v value:%v\n", evt.Type, string(evt.Kv.Key), string(evt.Kv.Value))
}
}
}
运行代码
haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/haimait/learn/etcd/etcd_watch$ go run main.go
connect to etcd success
Type:PUT key:/logagent/collect_config value:[{"path":"c:/tmp/nginx1111.log","topic":"web.log"},{"path":"d:/xxx/redis.log","topic":"redis.log"},{"path":"d:/xxx/mysql.log","topic":"mysql.log"}]
可以看到,当key /logagent/collect_config
的值变化时,会自动监听到
我的代码目录
.
├── etcd_put
│ ├── go.mod
│ ├── go.sum
│ └── main.go
└── etcd_watch
├── go.mod
├── go.sum
└── main.go
Golang ETCD包的安装使用 golang安装etcd第三方库clientv3 报错 解决的更多相关文章
- Python安装第三方库,报错超时: Read timed out.
1.安装beautifulsoup4 >pip install beautifulsoup4 报错超时: Read timed out. 2.解决办法:pip --default-timeout ...
- PowerPivot安装完成后创建网站或网站集报错解决办法
根据上一篇“在现有 SharePoint 服务器上安装 PowerPivot for SharePoint”后,新建网站或网站集时报错,重新配置了一下PowerPivot For SharePoint ...
- python使用pip安装库超时报错解决办法
原因:pip源超时了,安装不上 pip install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.c ...
- 部署war包后,新增tomcat服务器,启动tomcat服务器报错解决方法
导入Maven工程后,新增tomcat服务器,启动服务器后,报如下错误: 使用http访问页面的时候报如下错误: 经过百度后,有一种方法可以解决: 在eclipse tomcat无法启动,无法访问to ...
- R语言安装openxl包报错解决办法
在R语言中使用openxlsx包,会报错 解决办法就是: 下载安装Set-Rtool,安装时注意勾选对话框 然后在R中运行以下代码: Sys.setenv("R_ZIPCMD" = ...
- virtualbox装配fedora时,安装增强功能包时会报错解决
virtualbox安装fedora时,安装增强功能包时会报错解决 Building the main GuestAdditions module [失败]安装前需要先安装下面几个包才可以避免这个问题 ...
- MySQL5.7.26安装及启动报错解决
一.安装依赖包 [root@db01 ~]# yum install -y lrzsz [文件上传/下载] [root@db01 ~]# yum -y install xfsprogs [安装磁盘格式 ...
- Pycharm:安装anaconda中没有的第三方库
Pycharm需要用到的pyKriging第三方库库,但是下载了Anaconda后无法在Pycharm中搜到,之前还能搜到的,所以一定是因为Anaconda的原因,后来经过摸索,终于找到了解决问题的办 ...
- CentOS 7(Linux)安装docker,执行yum install docker-io -y报错
CentOS 7(Linux)安装Docker,执行yum install docker-io -y报错 一.执行yum install docker-io -y报错 Error: docker-ce ...
- 14、CentOS7安装过程中,磁盘大于2T的报错处理
问题描述 服务器磁盘单盘空间大于2TB,在安装CentOS7时出现下图报错: Boot failure.Reboot and Select proper Boot device... 问题原因: 安装 ...
随机推荐
- kubeadm init cannot find network namespace 错误
使用 kubeadm 安装好 weave 网络插件之后,查看 kubelet 输出信息发现如下错误: 4月 25 13:51:48 k8s-master kubelet[1232730]: I0425 ...
- MySQL数据库维护和改善性能
备份数据 由于MySQL数据库是基于磁盘的文件,普通的备份系统和例程就能备份MySQL的数据.但是,由于这些文件总是处于打开和使用状态,普通的文件副本备份不一定总是有效.下面列出这个问题的可能解决 ...
- 进程管理与 SELinux
进程管理与 SELinux 在 Linux 系统当中:『触发任何一个事件时,系统都会将他定义成为一个进程,并且给予这个进程一个 ID ,称为 PID,同时依据启发这个进程的用户与相关属性关系,给予 ...
- C 多维数组、特殊字符和字符串函数详解
C 多维数组 数组,也称为单维数组.这些非常棒,是您在 C 语言编程中会经常使用的东西.然而,如果您想要将数据存储为表格形式,例如带有行和列的表格,则需要熟悉多维数组. 二维数组 二维数组也称为矩阵, ...
- 6本值得推荐的MySQL学习书籍(有赠书福利)
前言 在DotNetGuide技术社区交流群和微信公众号后台经常收到小伙伴们的留言,让我出一期MySQL相关学习书籍的推荐文章.因此,今天我特意为大家精选了 6 本值得推荐的 MySQL 学习书籍,希 ...
- vs报错:RC1004 unexpected end of file found
如图,在编译代码时,出现报错:RC1004 unexpected end of file found 原因是,cpp最后要多一行才行,不然就会报这个错误 错误示例: int main() { ret ...
- Qt 5.12.10 国际化
网上有资料但是不全,所以这里记录一份比较全的 1.创建项目 2.编辑 demo.cpp 这里写button用来做国际化示例,运行软件后是这个样子 #include "demo.h" ...
- .gitignore 基础
前言 gitignore文件有几种方式生成. 1.在创建版本库的时候生成. 2.自己手动添加: windows环境下,不能把文件直接改名为.gitignore,会提示你必须输入文件名.所以我们先新建一 ...
- c# TryParse
c# tryparse和parse对比,大体内容是一致的. parse 会返回异常,主要表现为三种. 第一种ArgumentNullException,这里面表示,为空. 第二种formatexcep ...
- 深度解读《深度探索C++对象模型》之默认构造函数
接下来我将持续更新"深度解读<深度探索C++对象模型>"系列,敬请期待,欢迎关注!也可以关注公众号:iShare爱分享,主动获得推文. 提到默认构造函数,很多文章和书籍 ...