go

SQL Server解惑——查询条件IN中能否使用变量

雨燕双飞 提交于 2021-01-19 12:57:37
在SQL Server的查询条件中,能否在IN里面使用变量呢? 如果可以的话,有没有需要注意的地方或一些限制呢?在回答这个问题前,我们先来看看这个例子: IF EXISTS ( SELECT 1 FROM sys.objects WHERE name= 'TEST' AND type= 'U' ) BEGIN DROP TABLE TEST; END GO CREATE TABLE TEST ( ID INT , NAME VARCHAR (16) ); GO INSERT INTO dbo.TEST SELECT 1, 'a' UNION ALL SELECT 2, 'b' UNION ALL SELECT 3, 'c' UNION ALL SELECT 4, 'a,b' UNION ALL SELECT 5, '' 'b' ',' 'c' '' UNION ALL SELECT 6, '' 'b' ; GO 如下所示,如果查询条件里面,变量只有一个值,此时SQL是正常的。 DECLARE @name VARCHAR (16); SET @name= 'a' ; SELECT * FROM TEST WHERE name IN (@name); GO DECLARE @name VARCHAR (16); SET @name= 'a,b' ; SELECT * FROM TEST

Go语言开发Excel导表工具(上)

て烟熏妆下的殇ゞ 提交于 2021-01-19 07:55:24
Go语言开发Excel导表工具(上) 前言 游戏开发中经常会遇到将Excel文件导出配置的需求,鉴于之前的导表工具面对数据比较多的表格(尤其是多语言表格)导致导表速度很慢,因此想自己实现一个导表工具。 调研 目前市面上编程语言比较多:Node、Python、C#、Go... 以前项目中有用C#的也有用Python的,对比发现Python导表还是挺快的。(后来发现其实使用不同的Excel读取插件,执行效率还各有不同)在前期调研中发现了网站 https://zhuanlan.zhihu.com/p/29847628 , 里面说是Go语言执行效率高,那就拿他试试吧。 Go语言 其实对于新语言,一开始就要了解它的语法,这里推荐一个网站 https://www.runoob.com/go/go-tutorial.html 里面都是一些简单的基础语法。 环境配置 目前选用JetBrains公司的GoLand编程工具 下载Go https://golang.google.cn/dl/ 下载GoLand https://www.jetbrains.com/go/ 安装好之后这里需要设置一下GOPATH, 如图的目录就是用来下载后面Go语言相关的package包。 开发 Go语言需要一个main函数,同一个文件夹下面的文件的package包名必须要一致,不然IDE会报错。具体的导表逻辑下篇会介绍。

Custom Gorm preloading does not fetch data

我是研究僧i 提交于 2021-01-18 06:28:11
问题 I have a query that fetches rows from jobs table and its author (each job has an author ), but I want to select specific fields. type User struct { ID uint `gorm:"primarykey" json:"-"` UUID uuid.UUID `gorm:"type:uuid not null" json:"-"` Email string `gorm:"type:varchar(255); not null" json:"email"` Name string `gorm:"type:varchar(255); not null" json:"name"` AvatarURL string `gorm:"type:varchar(255); not null" json:"avatar_url"` Provider string `gorm:"type:varchar(255); not null" json:

Firestore DeadlineExceeded exception for big collections

眉间皱痕 提交于 2021-01-18 04:36:47
问题 I'm trying to read bigger collections from Google Firestore for testing and archiving purposes. I'm hitting some interesting errors when I try to get all documents from collections with more than 6k documents in them. Naive Python solution My first try was using the Python google-cloud-firestore (version 0.30.0) library. source_client = firestore.Client() source = source_client.collection(collection) source_data = source.get() counter = 0 for f in source_data: app.logger.info(f.id) counter +=

Firestore DeadlineExceeded exception for big collections

人盡茶涼 提交于 2021-01-18 04:35:44
问题 I'm trying to read bigger collections from Google Firestore for testing and archiving purposes. I'm hitting some interesting errors when I try to get all documents from collections with more than 6k documents in them. Naive Python solution My first try was using the Python google-cloud-firestore (version 0.30.0) library. source_client = firestore.Client() source = source_client.collection(collection) source_data = source.get() counter = 0 for f in source_data: app.logger.info(f.id) counter +=

Firestore DeadlineExceeded exception for big collections

寵の児 提交于 2021-01-18 04:28:22
问题 I'm trying to read bigger collections from Google Firestore for testing and archiving purposes. I'm hitting some interesting errors when I try to get all documents from collections with more than 6k documents in them. Naive Python solution My first try was using the Python google-cloud-firestore (version 0.30.0) library. source_client = firestore.Client() source = source_client.collection(collection) source_data = source.get() counter = 0 for f in source_data: app.logger.info(f.id) counter +=

Firestore DeadlineExceeded exception for big collections

醉酒当歌 提交于 2021-01-18 04:27:26
问题 I'm trying to read bigger collections from Google Firestore for testing and archiving purposes. I'm hitting some interesting errors when I try to get all documents from collections with more than 6k documents in them. Naive Python solution My first try was using the Python google-cloud-firestore (version 0.30.0) library. source_client = firestore.Client() source = source_client.collection(collection) source_data = source.get() counter = 0 for f in source_data: app.logger.info(f.id) counter +=

【基本流程控制】3. for语句

醉酒当歌 提交于 2021-01-17 21:05:12
Go语言-for语句 for 语句代表着循环。一条语句通常由关键字 for 、初始化子句、条件表达式、后置子句和以花括号包裹的代码块组成。其中,初始化子句、条件表达式和后置子句之间需用分号分隔。示例如下: for i := 0; i < 10; i++ { fmt.Print(i, " ") } 我们可以省略掉初始化子句、条件表达式、后置子句中的任何一个或多个,不过起到分隔作用的分号一般需要被保留下来,除非在仅有条件表达式或三者全被省略时分号才可以被一同省略。 我们可以把上述的初始化子句、条件表达式、后置子句合称为 for 子句。实际上, for 语句还有另外一种编写方式,那就是用 range 子句替换掉 for 子句。 range 子句包含一个或两个迭代变量(用于与迭代出的值绑定)、特殊标记 := 或 = 、关键字 range 以及 range 表达式。其中, range 表达式的结果值的类型应该是能够被迭代的,包括:字符串类型、数组类型、数组的指针类型、切片类型、字典类型和通道类型。例如: for i, v := range "Go语言" { fmt.Printf("%d: %c\n", i, v) } 对于字符串类型的被迭代值来说, for 语句每次会迭代出两个值。第一个值代表第二个值在字符串中的索引,而第二个值则代表该字符串中的某一个字符。迭代是以索引递增的顺序进行的。例如

干货!21条常用的Linux 命令

淺唱寂寞╮ 提交于 2021-01-17 09:00:22
阅读本文大概需要 7.8 分钟。 来源: http://t.cn/EqTIhES 一、文件和目录 1. cd命令 (它用于切换当前目录,它的参数是要切换到的目录的路径,可以是绝对路径,也可以是相对路径) cd /home 进入 '/ home' 目录 cd .. 返回上一级目录 cd ../.. 返回上两级目录 cd 进入个人的主目录 cd ~user1 进入个人的主目录 cd - 返回上次所在的目录 2. pwd命令 pwd 显示工作路径 3. ls命令 查看文件与目录的命令,list之意) ls 查看目录中的文件 ls -l 显示文件和目录的详细资料 ls -a 列出全部文件,包含隐藏文件 ls -R 连同子目录的内容一起列出(递归列出),等于该目录下的所有文件都会显示出来 ls [0-9] 显示包含数字的文件名和目录名 4. cp命令 (用于复制文件,copy之意,它还可以把多个文件一次性地复制到一个目录下) -a :将文件的特性一起复制 -p :连同文件的属性一起复制,而非使用默认方式,与-a相似,常用于备份 -i :若目标文件已经存在时,在覆盖时会先询问操作的进行 -r :递归持续复制,用于目录的复制行为 -u :目标文件与源文件有差异时才会复制 5. mv命令 (用于移动文件、目录或更名,move之意) -f :force强制的意思,如果目标文件已经存在

[译]Go 语言增加泛型的提案

℡╲_俬逩灬. 提交于 2021-01-17 06:55:31
原文地址:https://blog.golang.org/generics-proposal 原文作者:Ian Lance Taylor 本文永久链接:https://github.com/gocn/translator/blob/master/2021/w3_a_proposal_for_adding_generics_to_go.md 译者:cvley 校对:guzzsek 泛型提案 我们提出一个Go语言变更提案,用于让类型系统和函数支持类型参数,类型参数使通用编程模式成为可能。 为什么支持泛型? 泛型可以提供强大的构建代码块,让代码共享和程序构建更加简便。泛型编程意味着可以先实现功能和定义数据结构,而准确的类型可以留到后面指定。比如,一个操作某些任意数据类型切片的函数,当函数被调用时才会指定实际的数据类型。或者,一个存储任意类型的数据结构,当创建这个数据结构实例时,才会指定实际存储的类型。 自从Go在2009年首次发布后,泛型的支持一直都是最常见的语言特性需求之一。在之前的博文中,你可以了解更多泛型有用的原因。 尽管泛型有明确的使用场景,但将它融入到像Go一样的语言中是非常困难的。在Go中首次(有缺陷的)添加泛型的尝试可以追溯到2010年。在过去的十年中也有多次其他的尝试。 在过去的几年中,我们在设计草案上的一系列工作,最终形成了一个基于类型参数的设计方案