go

How to write a antlr4 visitor

痴心易碎 提交于 2021-01-07 02:31:11
问题 I am trying to write a visitor for a simple antlr4 grammar - I am adapting from the following example from the book: * directory tour * example: LabeledExpr.g4, EvalVisitor.java, Calc.java Based on the java code, I have written the following go code: package main import ( "os" "./parser" "github.com/antlr/antlr4/runtime/Go/antlr" ) type evalVisitor struct { *parser.BaseLabeledExprVisitor } func (v *evalVisitor) VisitAddSub(c *parser.AddSubContext) int { left := v.Visit(c.Expr(0)) right := v

How to write a antlr4 visitor

隐身守侯 提交于 2021-01-07 02:28:14
问题 I am trying to write a visitor for a simple antlr4 grammar - I am adapting from the following example from the book: * directory tour * example: LabeledExpr.g4, EvalVisitor.java, Calc.java Based on the java code, I have written the following go code: package main import ( "os" "./parser" "github.com/antlr/antlr4/runtime/Go/antlr" ) type evalVisitor struct { *parser.BaseLabeledExprVisitor } func (v *evalVisitor) VisitAddSub(c *parser.AddSubContext) int { left := v.Visit(c.Expr(0)) right := v

Ldap search for all members using a group with “#” in the name

三世轮回 提交于 2021-01-07 01:44:14
问题 The implementation below works for regular group names but fails with groups with "#" in the name. First I search for the DN of the group: group = "#ABCDE" filter := fmt.Sprintf("(&(objectCategory=group)(cn=%s)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))", ldap.EscapeFilter(group)) sr, err := l.Search(&ldap.SearchRequest{ BaseDN: "dc=ad,dc=some", Scope: 2, // subtree Filter: filter, Attributes: []string{"member", "cn", "dn"}, //Attributes: []string{"member", "cn", "dn", "samaccountname"

Ldap search for all members using a group with “#” in the name

岁酱吖の 提交于 2021-01-07 01:42:53
问题 The implementation below works for regular group names but fails with groups with "#" in the name. First I search for the DN of the group: group = "#ABCDE" filter := fmt.Sprintf("(&(objectCategory=group)(cn=%s)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))", ldap.EscapeFilter(group)) sr, err := l.Search(&ldap.SearchRequest{ BaseDN: "dc=ad,dc=some", Scope: 2, // subtree Filter: filter, Attributes: []string{"member", "cn", "dn"}, //Attributes: []string{"member", "cn", "dn", "samaccountname"

Mapping one type to another

帅比萌擦擦* 提交于 2021-01-07 01:36:17
问题 Let's say I have the following types. type Contract struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` ContractTypeId int `json:"contract_type_id" gorm:"column:contract_type_id"` } type ContractModel struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` } I have a SQL query using gorm to scan results

Mapping one type to another

﹥>﹥吖頭↗ 提交于 2021-01-07 01:36:15
问题 Let's say I have the following types. type Contract struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` ContractTypeId int `json:"contract_type_id" gorm:"column:contract_type_id"` } type ContractModel struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` } I have a SQL query using gorm to scan results

Mapping one type to another

只谈情不闲聊 提交于 2021-01-07 01:35:19
问题 Let's say I have the following types. type Contract struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` ContractTypeId int `json:"contract_type_id" gorm:"column:contract_type_id"` } type ContractModel struct { Id string `json:"id" gorm:"column:uuid"` Name string `json:"name" gorm:"column:name"` Description string `json:"descr" gorm:"column:descr"` } I have a SQL query using gorm to scan results

Docker Kubernetes 环境搭建

久未见 提交于 2021-01-06 19:00:27
Docker Kubernetes 环境搭建 节点规划 版本 系统 :Centos 7.4 x64 Docker版本: 18.09.0 Kubernetes版本: v1.8 etcd存储版本 :etcd-3.2.22 部署 管理节点 :192.168.1.79 安装插件:etcd 安装插件:kube-apiserver 安装插件:kube-controller-manager 安装插件:kube-scheduler 工作节点 :192.168.1.78 安装插件:kubelet 安装插件:kube-proxy 安装插件:docker 工作节点 :192.168.1.77 安装插件:kubelet 安装插件:kube-proxy 安装插件:docker Kubernetes 部署方式 1、kubeadm工具快捷安装kubernetes集群。 kubeadm工具安装会屏蔽很多细节。 2、通过kubernetes二进制包安装。 kubernetes二进制包: https://github.com/kubernetes/kubernetes kubernetes是基于GO语言开发的需要安装Go语言环境。 注: 这里我采用第2种,由于安装环境繁琐,将事先编译好的Kubernetes工具包来进行环境部署。 kubernetes工具包:https://pan.baidu.com/s

Go make 和 new的区别

爱⌒轻易说出口 提交于 2021-01-06 07:31:29
在Go语言中: make 被用来分配引用类型的内存: map, slice, channel new 被用来分配除了引用类型的所有其他类型的内存: int, string, array等 本文主要给大家介绍了Go语言中函数new与make的使用和区别,关于Go语言中new和make是内建的两个函数,主要用来创建分配类型内存。在我们定义生成变量的时候,可能会觉得有点迷惑,其实他们的规则很简单,下面我们就通过一些示例说明他们的区别和使用,话不多说了,来一起看看详细的介绍吧。 变量的声明 ? 1 2 var i int var s string 变量的声明我们可以通过var关键字,然后就可以在程序中使用。当我们不指定变量的默认值时,这些变量的默认值是他们的零值,比如int类型的零值是0,string类型的零值是"",引用类型的零值是nil。 对于例子中的两种类型的声明,我们可以直接使用,对其进行赋值输出。但是如果我们换成引用类型呢? ? 1 2 3 4 5 6 7 8 9 package main import ( "fmt" ) func main() { var i *int *i=10 fmt.Println(*i) } 这个例子会打印出什么?0还是10?。以上全错,运行的时候会painc,原因如下: ? 1 panic: runtime error: invalid memory