精华内容
下载资源
问答
  • CREATE TABLE users (user_id INT(8) NOT NULL AUTO_INCREMENT,user_name VARCHAR(30) NOT NULL,user_pass VARCHAR(255) NOT NULL,user_email VARCHAR(255) NOT NULL,user_date DATETIME NOT NULL,user_l...

    CREATE TABLE users (

    user_id INT(8) NOT NULL AUTO_INCREMENT,

    user_name VARCHAR(30) NOT NULL,

    user_pass VARCHAR(255) NOT NULL,

    user_email VARCHAR(255) NOT NULL,

    user_date DATETIME NOT NULL,

    user_level INT(8) NOT NULL,

    UNIQUE INDEX user_name_unique (user_name),

    PRIMARY KEY (user_id)

    ) TYPE=INNODB;

    When running this query on the SQL server, I am getting the following error:

    1064- You have an error in your SQL syntax; check the manual that corresponds to

    your MySQL server version for the right syntax to use near 'TYPE=INNODB' at line 10

    Any help on why this is coming up?

    解决方案

    Instead of

    TYPE=INNODB

    set

    Engine=InnoDB

    展开全文
  • 逻辑英语语法笔记

    万次阅读 多人点赞 2019-04-02 21:32:03
    逻辑英语语法笔记 该笔记是笔者学习钟平老师的逻辑英语英语语法的笔记,主要目的总结和复习,如需要更深入学习请到网易有道精品课里学习。 一、中英文对切公式 1、基本公式 主干相同:主谓宾位置不变 ...

    逻辑英语语法笔记


    该笔记是笔者学习钟平老师的逻辑英语英语语法的笔记,主要目的总结和复习,如需要更深入学习请到网易有道精品课里学习。


    一、中英文对切公式

    1、基本公式

    在这里插入图片描述

    • 主干相同:主谓宾位置不变
    • 修饰语英文后置,中文前置:定语修饰名词,状语修饰动词
    • 句子前后状语位置灵活:状语1在中英文对切时位置不固定,根据句意来定
    • 复杂定语内部按修饰顺序排序:修饰顺序通常为倒序(并列不变序),短语包括介词短语、从句、分词结构

    2、翻译(英译中)

    • 找主语:句首的名词性独立结构,包括名词、分词、代词、从句、it(形式主语)。
    • 找谓语:排除法,从句和介词短语中的动词,主语之前的动词,前面没有助词的分词都不是谓语,谓语可以是动词词组。
    • 修饰语前置:定语和状语都前置
    • 复杂定语内部排序
    • 从句按单个句子翻译

    3、复合句

    分类:

    • 并列句:并列复合句 (compound sentence),并列连词:and、or、but、so、for、 neither…nor… 、 either… or…、not only…but also…。并列的句子可以单独存在。
    • 复杂句:主从或从属复合句(complex sentence),由一个主句(Principal Clause)和一个或一个以上的从句(Subordinate Clause)构成。主句是全句的主体,通常可以独立存在;从句则是一个句子成分,不能独立存在。从句不能单独成句,但它也有主语部分和谓语部分,就像一个句子一样,但从句须由一个关联词(conjunction)引导。

    长难句,先找并列,再单独处理

    • 可以有多个并列,前面的并列用 ‘,’ 隔开,最后一个用 and 或 , and 连接
    • 从句种可以嵌套从句
    • 长难句: As a result of two or three centuries of scientific investigation we have come to believe that nature is understandable in the sense that when we ask her questions by way of appropriate observations and experiments, she will answer truly and reward us with discoveries that endure.
      结构分析: 主干 … we have come to believe that …。句子开头 as a result of 引导的原因状语从句,主句中的 that 从句作 believe 的宾语从句;此从句中的 that 从句作 the sense 的同位语从句;同位语从句中又套嵌一个由 when 引导的时间状语从句;此时间状语从句又套嵌一个定语从句 that endure,修饰其先行词discoveries。
      译文: 由于两三个世纪以来的科学研究成果,我们逐渐相信,如果运用合适的观察和实验方法向大自然探究问题,她会真心实意地给我们答复,并且以永垂不朽的发现来报答我们。从这个意义上来说,大自然是可以认识的。

    句子并列(双黄蛋):找并列连词

    • 句子有时可以省略一些可推导出来的成分

       I like action movies but don't like thrillers.
       Hurry up or you'll be late. 
       找并列连词 and、or
      

    句子成分并列(单黄蛋):找相同结构

    • 并列成分的格式必须一致,两个词、两个短语、两个分句,不能一个是词一个是句子

       In your life, a man who helps you when you are in trouble 
       and who leaves you when you are successful is a real friend. 
       结构:a man who... who...
      
       Science, in practice, depends less on the experiment it prepares than 
       on the preparedness of the minds of the men who watch the experiments.  
       结构:depend less on... than on
      

    二、时态

    1、点时间和段时间

    • 点时间:动作发生的具体时间,用现在、过去、将来及其进行时。 last night, ten o’clock, April 1st, next year, 1994

    • 段时间:动作在哪一段时间内发生(不关心具体时间),用完成、完成进行时。 from…to…, whole year, so far, up to now

    • 去年表示点时间,去年一整年表示段时间

       I saw the film last night.   
       我昨晚看过那个电影了。(昨晚这个具体时间点看的)
       
       I had seen the film before last night.   
       我昨晚之前已经看过那个电影了。(昨晚这个具体时间点之前的任一时间点看的)
      

    2、各种时态

    在这里插入图片描述

    主动时态一般进行完成完成进行
    现在be(am, is, are)/do/doesbe(am, is, are) doinghave/has donehave/has been doing
    过去was/were/didwas/were doinghad donehad been doing
    将来will/shall dowill/shall be doingwill/shall have donewill/shall have been doing
    过去将来would/should dowould/should be doingwould/should have donewould/should have been doing
    被动时态一般进行完成
    现在am/is/are done ; can/may/must be doneam/is/are being donehave/has been done
    过去was/were done ; might/could/had to be donewas/were being donehad been done
    将来will/shall be done; am/is/are going to be done-will/shall have been done
    过去将来would/should be done-would/should been done

    三、虚拟语气

    时态提前:虚拟语气是对事实的虚拟,与事实相反,所以时态故意用错,强调这是虚拟的

    虚拟从句主句
    现在did/werewould do
    过去had donewould have done
    将来should do / were towould do

    用虚拟表示愿望:希望这样但是现实不是这样

    It's time that we went to work.
    我们应该去干活了(还没有干)。went 表示虚拟。
    
    I wish you could do a good job.
    我希望你能好好干活(言下之意可能是你现在没有好好干)。could 表示虚拟。
    
    if only:要是...就好了(事实不是那样)
    would rather: 宁愿...(事实不是选择那样)
    

    四、定语从句

    定语从句
    定语从句(Attributive Clauses)指句子跟在一名词或代词(先行词)后进行修饰限定,起形容词作用的句子。定语从句不同于单词作定语的情况,它通常只能放在被修饰的词(即先行词)之后。

    合并同类项:

    • 合并两个句子中相同的成分(先行词),前一句保留,后一句用关系词代替

    • 介词不能省略,可以保留位置不变,如果不会改变句子的意思也可以作为关系词的一部分

       I know the man, the man is crying in the car.
       I know the man who is crying in the car.
       合并两个 the man 后面的 the man 用 who 代替
      
       I do not like books,books do not have pictures.
       I do not like books which do not have pictures.
        后一句的 books 用 which 代替
      
       I hate the city, in the city I met him.
       I hate the city in which I met him.
       I hate the city where I met him.
       介词 in 不能省略,in which = where
       
       I have forgotten the day when(on which)you came.				
       Today will be a day which You will remember for life.
       第一句的 day 是作为后面的状语,第二句的 day 是作为后面的宾语,用心体会
       
       This is the book which I am looking for.
       介词 for 不能提前,look(看) 和 look for(寻找) 意思不一样
      

    关系词:

    • who/whom:先行词是人,做主语用 who,做宾语用 whom;
    • which:先行词是物
    • that:先行词是人、是物都可以,有介词的 which 最好不要用 that 代替
    • 介词 + which = 关系副词:on which = when;in which = where;for which = why;which’s = whose。
    • 先行词在从句中充当宾语的可以省略关系词

    五、状语从句

    状语从句:
    状语从句(Adverbial Clause)指句子用作状语时,起副词作用的句子。状语从句中可以修饰谓语、非谓语动词、定语、状语或整个句子。根据其作用可分为时间、地点、原因、条件、目的、结果、让步、方式和比较等从句。状语从句一般由连词(从属连词)引导,也可以由词组引起。从句位于句首或句中时通常用逗号与主句隔开,位于句尾时可以不用逗号隔开。

    • 状语其实比较啰嗦

    独立结构:
    去掉从句中一切不必要的句子成分,根据主被动关系改变动词的形式

    • 去掉某些成分就不是一个句子了,既然不是一个句子了,就不能用谓语了,要把谓语变成分词形式。主动:v-ing;被动:v-ed

    • 如果从句和主句的主语不一致,不能省略从句中的成分

       Because she knows what I need, she can provide a right answer.
       Knowing what I need, she can provide a right answer.
       去掉从句中可以从主句中推导出来的成分和连词,修改动词的形式
       
       when i was a boy, my father taught me to swim.
       Being a boy, my father taught me to swim. (错误)
       从句和主句的主语不一致,会产生歧义,从句不能省略成分
      

    连词:

    • 时间:when, as, while, as soon as, before, after, since, not…until(直到…才), until/till(直到…时)
    • 地点:where, wherever, anywhere, everywhere
    • 原因:because, since, as, seeing that, considering that, given that
    • 条件:if, unless, whether(whether…or not),as/so long as, only if, providing/provided that, supposing that, in case, on condition that
    • 目的:so that, in order that, lest(以免), in case(以防万一), for the purpose of
    • 让步:though, although, even if, even though, as(用在让步状语从句中必须要倒装), while, no matter …,whatever
    • 比较:as(同级比较), than(不同程度的比较), the more … the more …, no … more than, the 比较级, the 比较级.
    • 方式:as(像…一样), as if(好像), the way
    • 结果:so … that, such … that, so that…,such that, to such a degree that(某种程度上)

    六、名词性从句

    名词性从句: 名词性从句(Noun Clause)是指在句子中起名词作用的句子。 名词性从句的功能相当于名词词组, 它在复合句中能担任主语、宾语、表语、同位语、介词宾语等,根据它在句中不同的语法功能,名词性从句又可分别称为主语从句、宾语从句、表语从句和同位语从句。

    That you love her is a lie.
    主语从句
    
    I don't know what you can do.
    宾语从句,注意 what 后面是陈述语序
    		
    She hates the idea that we should abandon her.
    同位语从句
    

    连词:

    • that :本身无意义,引导单一的宾语从句时常可省略,但引导主语从句、表语从句、同位语从句时通常不被省略。
    • whether, if (是否);as if, as though ( 好像、似乎)
    • 连接代词:what/ whatever, who/ whoever, whom/ whomever, whose/whosever, which/ whichever
    • 连接副词:when/ whenever, where/ wherever, how/ however, why,because

    七、名词

    1、可数不可数

    名词可数不可数的区分标准是有没有固定的单位,可数名词有固定的单位,不可数名词没有。

    • orange 作为橙子,单位是个可数;作为橙汁,没有固定单位不可数
    • coffee 一开始也没有固定单位不可数,后来大家默认一杯为咖啡的固定单位就变成了可数

    名词可数不可数跟有没有必要数有关,没必要数/不关心的时候是为不可数,有必要数/关心的时候为可数

    • salty 盐,sand 沙子,sugar 糖没必要数,谁数谁傻逼
    • hair 头发当作整体的时候没必要数,但如果是床上有三根头发(three hairs)就变成了可数。

    2、就近就远原则

    重点是谁,谓语就根据谁而定:重心是二者之一就选那个重要的,两者平行就近,两者并列复数

    • A woman with two children is coming.
    • Not only I but also he is right.
    • Both I and he are right.

    There be 句型,就近选择:没有主语,所以就近

    • There is an apple and two pears on the table.
    • There are two pears and an apple on the table.

    3、集合名词的数量逻辑

    集合作为整体(不一定每个成员都这样,只是总体是这样)用单数,强调集合中的每个成员都这样用复数。

    • My family is rich. 我家很有钱,但并不一定是每个成员都有钱
    • My family are crazy. 我家的每个成员都疯了

    八、动词

    系动词:
    可以看做是“是动词”

    • be 动词(am/is/are):是…的

    • …是…的:seem,look,become,get,grow,feel,turn,appear,remain

       He looked carefully, but still looked perplexed
       虽然他很仔细的看,但看起来还是很懵逼
      

    谓语多个动词:
    当谓语有多个动词时,需要用特定的词进行连接,其实只有 v + to + v 这种形式,其它两种形式是这种形式的变形

    • v + to + v:to 表示过程,动作有先后关系。want to, go to, plan to。

    • v + v-原型:两者之间没有明确的先后关系,希望后面的动作快点发生,直接省略 to。使动词:let make get have。也有处于某种状态的含义。

       I make him eat shit
       He is made to eat shit
       我让他比较急,而他自己肯定不急,所以变成被动后要加上 to,好好体会
      
       I saw him work in the garden yesterday.  
       看到他工作了(强调工作这种状态)。
       I saw him working in the garden yesterday. 
       看到他正在工作(强调正在进行)。
      
    • v + v-ing:动作的先后关系反了,所以加 ing。有时主语不一致也用 ing 。也有正在进行的含义。

       I forget locking the door.
       我忘了锁过门这件事了(锁门是在忘了之前,所以门锁了)。		
       I forget to lock the door.
       我忘了去锁门了(锁门是在忘了之后,所以门没锁)。
       
       Nice to meet you.  
       去见你很高兴	(还没有见面)。
       Nice meeting you.
       见到你很高兴(已经见面了)。
      
       stop smoking
       停止抽烟(只有抽烟了才能叫他停止)。
       stop to smoking
       停下来取抽烟(先停下来再去抽烟)。
      
       I don't allow smoking
       我不允许有人抽烟(抽烟和允许的主语不一致)。
      

    非谓语
    非谓语通常做定语,本质是定语从句的省略,补全后就知道该用什么格式了。有些动词可以直接形容词/名词化。

    • ing:主动,令人…的(及物),正在(不及物)

    • ed:被动(及物),已经(不及物)

    • to do:去,为了,表示目的性

       There is a bird flying in the sky.
       There is a bird which is flying in the sky.
       定语从句的省略,表主动
      
       Those elected today shall take the responsibility. 
       Those who were elected today shall take the responsibility. 
       定语从句的省略,表被动
      
       To find love, you have to devote.
       You  are to find love, you have to devote.
      

    九、其它

    1、同位语

    同位语: 一个名词/句子对另一个名词/代词进行解释或补充说明,这个名词/句子就是同位语。同位语与被它限定的词的格式要一致,并常常紧挨在一起。

    • 名词同位语:可以有多个名词同位语并列,逗号隔开,名词同位语还可以有定语/定语从句

    • 句子同位语:that 在同位语句中不充当任何成分

       Tom, my brother, a teacher who teaches me English, is coming
       句子同位语并列。is 表示一个
      
       She hates the idea that we should work hard.
       句子同位语。idea 在句子同位语中不充当任何成分
      

    2、倒装句

    倒装句: 为了强调、突出等词语的目的而颠倒原有语序的句式叫做倒装句。在倒装句中,颠倒了的成分可以恢复原位而句意基本不变,句法成分不变。与正常语句结构不一样突出要强调的东西

    • 强调否定副词状语:副词和助词都提前,半倒装。Never, seldom, scarcely, hardly, nowhere, nolonger

    • 强调时间/地点状语:状语和动词都提前,全倒装

    • 状语本来的位置就不固定,只提前状语不能突出要强调的意思

        I have never seem him so far.
        Never have i seem him so far.
        强调 never,提前状语和助词
      
        I can understand him only in this way.
        Only in this way can I understand him.
        强调 only in this way
      
        A cat lies in the house
        In the house lies a cat.
        强调 in the house,提前状语和动词
      

    3、强调句

    强调句:表达自己的意愿或情感而使用的一种形式。

    • 强调结构:It is/was + 被强调部分(主语、宾语或状语) + who/that…

    • 强调句去掉 It’s that 句子还是完整的,形式主语去掉 It’s that 句子不完整

       It's you that i love 
       强调句,强调 you,去掉 It's that 把 you 放后面句子还是完整的
       
       It's important that i love you
       It 是形式主语,代表 i love you,去掉 It's that 后多出了 important 句子不完整
      

    4、time 和 times

    time不加s表示时间,加s表次数

    sometime  某时	
    some time  一些时间	
    sometimes  有时
    some times  几次
    

    GOOD LUCK!


    展开全文
  • Go语言基础语法

    千次阅读 2019-07-23 11:57:05
    Go语言基础语法 一.go语言介绍 1.Go语言简介 Go 语言(或 Golang)起源于 2007 年,并在 2009 年正式对外发布。Go 是非常年轻的一门语言,它的主要目标是“兼具 Python 等动态语言的开发速度和 C/C++等编译型语言的...

    Go语言基础语法

    一.go语言介绍

    1.Go语言简介

    • Go 语言(或 Golang)起源于 2007 年,并在 2009 年正式对外发布。Go 是非常年轻的一门语言,它的主要目标是“兼具 Python 等动态语言的开发速度和 C/C++等编译型语言的性能与安全性”
    • Go 语言是编程语言设计的又一次尝试,是对类C语言的重大改进,它不但能让你访问底层操作系统,还提供了强大的网络编程和并发编程支持。Go 语言的用途众多,可以进行网络编程、系统编程、并发编程、分布式编程。
    • Go 语言的推出,旨在不损失应用程序性能的情况下降低代码的复杂性,具有“部署简单、并发性好、语言设计良好、执行性能好”等优势,目前国内诸多 IT 公司均已采用 Go 语言开发项目。
    • Go 语言有时候被描述为“C 类似语言”,或者是“21 世纪的 C 语言”。Go 从 C 语言继承了相似的表达式语法、控制流结构、基础数据类型、调用参数传值、指针等很多思想,还有 C 语言一直所看中的编译后机器码的运行效率以及和现有操作系统的无缝适配。
    • 因为 Go 语言没有类和继承的概念,所以它和 Java 或 C++ 看起来并不相同。但是它通过接口(interface)的概念来实现多态性。Go 语言有一个清晰易懂的轻量级类型系统,在类型之间也没有层级之说。因此可以说 Go 语言是一门混合型的语言。
    • 此外,很多重要的开源项目都是使用 Go 语言开发的,其中包括 Docker、Go-Ethereum、Thrraform 和 Kubernetes。

    2.Go语言创始人

    对语言进行评估时,明白设计者的动机以及语言要解决的问题很重要。Go 语言出自 Ken Thompson 和 Rob Pike、Robert Griesemer 之手,他们都是计算机科学领域的重量级人物。
    贝尔实验室 Unix 团队成员,C 语言、Unix 和 Plan 9 的创始人之一,在 20 世纪 70 年代,设计并实现了最初的 UNIX 操作系统,仅从这一点说,他对计算机科学的贡献怎么强调都不过分。他还与 Rob Pike 合作设计了 UTF-8 编码方案。

    2) Rob Pike

    Go 语言项目总负责人,贝尔实验室 Unix 团队成员,除帮助设计 UTF-8 外,还帮助开发了分布式多用户操作系统 Plan 9,,Inferno 操作系统和 Limbo 编程语言,并与人合著了《The Unix Programming Environment》,对 UNIX 的设计理念做了正统的阐述。
    就职于 Google,参与开发 Java HotSpot 虚拟机,对语言设计有深入的认识,并负责 Chrome 浏览器和 Node.js 使用的 Google V8 JavaScript 引擎的代码生成部分。

    Go 语言的所有设计者都说,设计 Go 语言是因为 C++ 给他们带来了挫败感。在 Google I/O 2012 的 Go 设计小组见面会上,Rob Pike 是这样说的:

    我们做了大量的 C++ 开发,厌烦了等待编译完成,尽管这是玩笑,但在很大程度上来说也是事实。
    

    3.Go语言优势

    • 语法简单
    	var a,b=1,2
    	a,b=b,a
    	fmt.Println(a,b)
    
    • 可以直接编译成机器码
    • 静态数据类型和编译语言
    	a:=1
    	b:=false
    
    • 内置支持并发
    	go func() {
    		//do something
    	}()
    
    • 内置垃圾回收
    • 部署简单
    • 强大的标准库

    4.Go是编译型语言

    Go 使用编译器来编译代码。编译器将源代码编译成二进制(或字节码)格式;在编译代码时,编译器检查错误、优化性能并输出可在不同平台上运行的二进制文件。要创建并运行 Go 程序,程序员必须执行如下步骤。

    1. 使用文本编辑器创建 Go 程序;

    2. 保存文件;

    3. 编译程序;

    4. 运行编译得到的可执行文件。

      这不同于 Python、Ruby 和 JavaScript 等语言,它们不包含编译步骤。Go 自带了编译器,因此无须单独安装编译器。

    5.为什么要学习Go语言

    如果你要创建系统程序,或者基于网络的程序,Go 语言是很不错的选择。作为一种相对较新的语言,它是由经验丰富且受人尊敬的计算机科学家设计的,旨在应对创建大型并发网络程序面临的挑战。

    在 Go 语言出现之前,开发者们总是面临非常艰难的抉择,究竟是使用执行速度快但是编译速度并不理想的语言(如:C++),还是使用编译速度较快但执行效率不佳的语言(如:.NET、Java),或者说开发难度较低但执行速度一般的动态语言呢?显然,Go 语言在这 3 个条件之间做到了最佳的平衡:快速编译,高效执行,易于开发。

    Go 语言支持交叉编译,比如说你可以在运行 Linux 系统的计算机上开发可以在 Windows 上运行的应用程序。这是第一门完全支持 UTF-8 的编程语言,这不仅体现在它可以处理使用 UTF-8 编码的字符串,就连它的源码文件格式都是使用的 UTF-8 编码。Go 语言做到了真正的国际化!

    6.Go语言适用场景

    • 服务器编程.实现日志处理,虚拟机处理,文件处理等
    • 分布式系统或数据库代理
    • 网络编程,包含web应用
    • 云平台

    7.市场占有率

    • 根据Tiobe中Go语言的排行在逐年上升.

    在这里插入图片描述

    8.Go语言吉祥物

    在这里插入图片描述

    二.环境变量配置

    1.下载地址

    • 由于Google退出中国,所以国内无法直接访问到Go语言的官网
    • 但是可以通过Go语言中文网进行加载资源和交流Go语言技术

    https://studygolang.com/

    2.下载步骤

    • 直接进入到Go语言中文网下载页面

    在这里插入图片描述

    • 选择要下载的版本
      • 首先要确定版本号,本套视频使用的Go1.10.1
      • 然后确定自己的操作系统,windows或linux等,本阶段使用Window操作系统进行讲解
      • 如果是windows确定自己系统位数,32位系统选择386,64位系统选择amd64
      • 扩展名.msi表示安装版.zip为解压版(推荐使用解压版,所有的配置都自己操作,心中有数)

    在这里插入图片描述

    3.Go语言库文件夹解释

    • api : 每个版本更新说明
    • bin : 自带工具. 重点记忆
    • blog:博客
    • doc:文档
    • misc: 代码配置
    • lib:额外引用
    • src:标准库源码,以后第三方库放入到这个文件夹中. 重点记忆
    • test:测试

    4.配置步骤(Windows举例)

    • 把下载好的go1.10.1.windows-amd64进行解压,解压后出现go文件夹

    在这里插入图片描述

    • 把解压后的go文件夹复制到任意非中文目录中(例如: D:\mysoftware\go\soft\go)
      • 如果没有配置环境变量默认去C:\go找Go语言库

    在这里插入图片描述

    • 配置环境变量
      • “我的电脑” --> 右键”属性”–> “高级” --> “环境变量” --> “系统变量”–> “新建”按钮后输入

    在这里插入图片描述

    • 在”系统变量”中PATH属性里面添加%GOROOT%\bin;

    在这里插入图片描述

    • 启动”命令行”输入go version如果出现下面效果说明配置成功
      • 也可以使用go env命令查看全部环境

    在这里插入图片描述

    5.环境变量参数解释

    • GOROOT 表示Go语言库的根目录的完整路径
    • PATH 中配置内容方便在命令行快速调用Go语言库中工具
    • GOPATH 可以先不配置,在做项目时需要配置,表示项目路径

    三.Hello World

    1.编写前准备

    • 在D:/盘下新建了一个文件夹,名称为go(这个文件夹名称任意,只要不是中文即可)
    • 在go文件夹下新建了一个文件夹,名称为0103,代表着这是章节1的第3小节
    • 为了能够在命令行中进行操作,需要先知道几个windows命令行命令
    盘符名:		 #表示进入到某个磁盘
    cd 文件夹名称	#表示进入到文件夹中
    cd .. 		   #表示向上跳一个文件夹
    dir			   #当前文件夹中内容展示
    
    • Go语言库bin目录下go.exe的run参数表示运行一个XXX.go文件
    go run XXX.go
    

    2.Hello World编写过程

    • 在D:/go/0103/新建记事本,并修改扩展名后名称为main.go
    • 在文件中输入以下代码
    package main
    
    import "fmt"
    
    func main() {
    	fmt.Println("Hello World")
    }
    
    • 使用Windows命令行工具,输入以下命令运行观察结果
    d:
    cd go/0103
    go run main.go
    
    • 程序结果应该是输出
    Hello World
    

    四.Hello World编写过程注意事项

    1.关于文件

    • 文件名称任意,尽量使用全英文文件名
    • 文件扩展名应该为.go ,对于初学者一定要注意,以下形式都是不对了
    main.go.txt
    main.txt
    

    2.注释

    • 注释是给程序员自己看的备注.防止忘记
    • 编译器不会编译注释中内容.注释对程序运行无影响
    • 注释支持单行注释和多行注释
    //单行注释 ,从双斜杠开始到这行结束的内容都是注释内容
    
    /*
    多行注释
    */
    

    3.package关键字

    • package表示当前代码所属的包(package),是一种组织结构.其他package通过包名调用这个包下内容
    • package是必须的,每个文件的package必须存在有效代码第一行
    • package main 是程序入口包,这个包中可以编写主函数

    4.import关键字

    • import表示导入包,引用其他包的内容
    • import "fmt"表示引用fmt包
      • fmt 包是Go语言库中自带的包,实现输入输出等功能
    • import 必须存在于package关键字下面,函数或变量声明的上面
    • import 导入包时包名两侧必须有双引号,支持以下几种语法
    //一个包一个包的导入
    import "fmt"
    import "os"
    
    // 一次导入多个包(此方式为官方推荐的方式)
    import (
    	"fmt"
    	"os"
    )
    
    • Go语言要求,导入包就必须使用,否则出现编译错误.例如导入了"fmt"和"os"包,如果只使用了"fmt"会出现一下错误信息
    imported and not used: "os"
    

    5.main函数

    • func main 称为主函数,是整个程序的入口,最先执行主函数中的代码
    • main()后面的 { 必须和func 在同一行,否则运行时提示下面信息
    .\main.go:6:syntax error:unexpected semicolon or newline before {
    
    • fmt.Println()后面不需要有分号,但是写分号也可以正常运行
      • 如果一行就一个语句习惯上是不写分号的
      • 如果一行有多个语句,每个语句后面要添加分号(不写推荐一行写多个)

    6.编码问题

    • Go语言适用UTF-8编码,编译整个文件
    • 新建的记事本默认ANSI编码,所以要有中文需要把文件保存为UTF8编码
      在这里插入图片描述

    7.其他事项

    • 整个文件中严格区分大小写

    五.Go工具

    1.解压版Go语言安装包中自带工具

    • 在%GOROOT%/bin中有三个工具
      • go.exe 编译、运行、构建等都可以使用这个命令
      • godoc.exe 查看包或函数的源码
      • gofmt.exe 格式化文件
    --bin
    	--go.exe
    	--godoc.exe
    	--gofmt.exe
    

    2.go.exe参数列表

    • 在命令行中通过go help查看go参数如下
    Usage:
    
            go command [arguments]
    
    The commands are:
    
            build       compile packages and dependencies
            clean       remove object files and cached files
            doc         show documentation for package or symbol
            env         print Go environment information
            bug         start a bug report
            fix         update packages to use new APIs
            fmt         gofmt (reformat) package sources
            generate    generate Go files by processing source
            get         download and install packages and dependencies
            install     compile and install packages and dependencies
            list        list packages
            run         compile and run Go program
            test        test packages
            tool        run specified go tool
            version     print Go version
    		vet         report likely mistakes in packages
    

    3.常用参数解释

    • go version查看Go语言版本
    • go env查看Go语言详细环境
    • go list查看Go语言文件目录
    • go build把源码文件构建成系统可执行文件
    • go clean清空生成的可执行文件
    • go vet静态解析文件,检查是否有语法错误等
    • go get从远程下载第三方Go语言库
    • go bug提交bug
    • go test测试(在后面章节中讲解)
    • go run运行文件

    六.godoc命令介绍

    1.godoc 命令介绍

    • 可以使用godoc [包] [函数名]查看包或函数的详细源码
    • 源码在学习中非常重要,经常查看源码方便理解GO的原理

    2.godoc使用

    • 查看包的源码
    C:\Users\zhang>godoc fmt
    use 'godoc cmd/fmt' for documentation on the fmt command
    
    PACKAGE DOCUMENTATION
    
    package fmt
        import "fmt"
    
        Package fmt implements formatted I/O with functions analogous to C's
        printf and scanf. The format 'verbs' are derived from C's but are
        simpler.
    
    
        Printing
    
        The verbs:
    
        General:
    
            %v      the value in a default format
                    when printing structs, the plus flag (%+v) adds field names
            %#v     a Go-syntax representation of the value
            %T      a Go-syntax representation of the type of the value
            %%      a literal percent sign; consumes no value
    
        Boolean:
    
            %t      the word true or false
    
        Integer:
    
            %b      base 2
            %c      the character represented by the corresponding Unicode code point
            %d      base 10
            %o      base 8
            %q      a single-quoted character literal safely escaped with Go syntax.
            %x      base 16, with lower-case letters for a-f
            %X      base 16, with upper-case letters for A-F
            %U      Unicode format: U+1234; same as "U+%04X"
    
        Floating-point and complex constituents:
    
            %b      decimalless scientific notation with exponent a power of two,
                    in the manner of strconv.FormatFloat with the 'b' format,
                    e.g. -123456p-78
            %e      scientific notation, e.g. -1.234456e+78
            %E      scientific notation, e.g. -1.234456E+78
            %f      decimal point but no exponent, e.g. 123.456
            %F      synonym for %f
            %g      %e for large exponents, %f otherwise. Precision is discussed below.
            %G      %E for large exponents, %F otherwise
    
        String and slice of bytes (treated equivalently with these verbs):
    
            %s      the uninterpreted bytes of the string or slice
            %q      a double-quoted string safely escaped with Go syntax
            %x      base 16, lower-case, two characters per byte
            %X      base 16, upper-case, two characters per byte
    
        Pointer:
    
            %p      base 16 notation, with leading 0x
            The %b, %d, %o, %x and %X verbs also work with pointers,
            formatting the value exactly as if it were an integer.
    
        The default format for %v is:
    
            bool:                    %t
            int, int8 etc.:          %d
            uint, uint8 etc.:        %d, %#x if printed with %#v
            float32, complex64, etc: %g
            string:                  %s
            chan:                    %p
            pointer:                 %p
    
        For compound objects, the elements are printed using these rules,
        recursively, laid out like this:
    
            struct:             {field0 field1 ...}
            array, slice:       [elem0 elem1 ...]
            maps:               map[key1:value1 key2:value2]
            pointer to above:   &{}, &[], &map[]
    
        Width is specified by an optional decimal number immediately preceding
        the verb. If absent, the width is whatever is necessary to represent the
        value. Precision is specified after the (optional) width by a period
        followed by a decimal number. If no period is present, a default
        precision is used. A period with no following number specifies a
        precision of zero. Examples:
    
            %f     default width, default precision
            %9f    width 9, default precision
            %.2f   default width, precision 2
            %9.2f  width 9, precision 2
            %9.f   width 9, precision 0
    
        Width and precision are measured in units of Unicode code points, that
        is, runes. (This differs from C's printf where the units are always
        measured in bytes.) Either or both of the flags may be replaced with the
        character '*', causing their values to be obtained from the next operand
        (preceding the one to format), which must be of type int.
    
        For most values, width is the minimum number of runes to output, padding
        the formatted form with spaces if necessary.
    
        For strings, byte slices and byte arrays, however, precision limits the
        length of the input to be formatted (not the size of the output),
        truncating if necessary. Normally it is measured in runes, but for these
        types when formatted with the %x or %X format it is measured in bytes.
    
        For floating-point values, width sets the minimum width of the field and
        precision sets the number of places after the decimal, if appropriate,
        except that for %g/%G precision sets the total number of significant
        digits. For example, given 12.345 the format %6.3f prints 12.345 while
        %.3g prints 12.3. The default precision for %e, %f and %#g is 6; for %g
        it is the smallest number of digits necessary to identify the value
        uniquely.
    
        For complex numbers, the width and precision apply to the two components
        independently and the result is parenthesized, so %f applied to 1.2+3.4i
        produces (1.200000+3.400000i).
    
        Other flags:
    
            +       always print a sign for numeric values;
                    guarantee ASCII-only output for %q (%+q)
            -       pad with spaces on the right rather than the left (left-justify the field)
            #       alternate format: add leading 0 for octal (%#o), 0x for hex (%#x);
                    0X for hex (%#X); suppress 0x for %p (%#p);
                    for %q, print a raw (backquoted) string if strconv.CanBackquote
                    returns true;
                    always print a decimal point for %e, %E, %f, %F, %g and %G;
                    do not remove trailing zeros for %g and %G;
                    write e.g. U+0078 'x' if the character is printable for %U (%#U).
            ' '     (space) leave a space for elided sign in numbers (% d);
                    put spaces between bytes printing strings or slices in hex (% x, % X)
            0       pad with leading zeros rather than spaces;
                    for numbers, this moves the padding after the sign
    
        Flags are ignored by verbs that do not expect them. For example there is
        no alternate decimal format, so %#d and %d behave identically.
    
        For each Printf-like function, there is also a Print function that takes
        no format and is equivalent to saying %v for every operand. Another
        variant Println inserts blanks between operands and appends a newline.
    
        Regardless of the verb, if an operand is an interface value, the
        internal concrete value is used, not the interface itself. Thus:
    
            var i interface{} = 23
            fmt.Printf("%v\n", i)
    
        will print 23.
    
        Except when printed using the verbs %T and %p, special formatting
        considerations apply for operands that implement certain interfaces. In
        order of application:
    
        1. If the operand is a reflect.Value, the operand is replaced by the
        concrete value that it holds, and printing continues with the next rule.
    
        2. If an operand implements the Formatter interface, it will be invoked.
        Formatter provides fine control of formatting.
    
        3. If the %v verb is used with the # flag (%#v) and the operand
        implements the GoStringer interface, that will be invoked.
    
        If the format (which is implicitly %v for Println etc.) is valid for a
        string (%s %q %v %x %X), the following two rules apply:
    
        4. If an operand implements the error interface, the Error method will
        be invoked to convert the object to a string, which will then be
        formatted as required by the verb (if any).
    
        5. If an operand implements method String() string, that method will be
        invoked to convert the object to a string, which will then be formatted
        as required by the verb (if any).
    
        For compound operands such as slices and structs, the format applies to
        the elements of each operand, recursively, not to the operand as a
        whole. Thus %q will quote each element of a slice of strings, and %6.2f
        will control formatting for each element of a floating-point array.
    
        However, when printing a byte slice with a string-like verb (%s %q %x
        %X), it is treated identically to a string, as a single item.
    
        To avoid recursion in cases such as
    
            type X string
            func (x X) String() string { return Sprintf("<%s>", x) }
    
        convert the value before recurring:
    
            func (x X) String() string { return Sprintf("<%s>", string(x)) }
    
        Infinite recursion can also be triggered by self-referential data
        structures, such as a slice that contains itself as an element, if that
        type has a String method. Such pathologies are rare, however, and the
        package does not protect against them.
    
        When printing a struct, fmt cannot and therefore does not invoke
        formatting methods such as Error or String on unexported fields.
    
        Explicit argument indexes:
    
        In Printf, Sprintf, and Fprintf, the default behavior is for each
        formatting verb to format successive arguments passed in the call.
        However, the notation [n] immediately before the verb indicates that the
        nth one-indexed argument is to be formatted instead. The same notation
        before a '*' for a width or precision selects the argument index holding
        the value. After processing a bracketed expression [n], subsequent verbs
        will use arguments n+1, n+2, etc. unless otherwise directed.
    
        For example,
    
            fmt.Sprintf("%[2]d %[1]d\n", 11, 22)
    
        will yield "22 11", while
    
            fmt.Sprintf("%[3]*.[2]*[1]f", 12.0, 2, 6)
    
        equivalent to
    
            fmt.Sprintf("%6.2f", 12.0)
    
        will yield " 12.00". Because an explicit index affects subsequent verbs,
        this notation can be used to print the same values multiple times by
        resetting the index for the first argument to be repeated:
    
            fmt.Sprintf("%d %d %#[1]x %#x", 16, 17)
    
        will yield "16 17 0x10 0x11".
    
        Format errors:
    
        If an invalid argument is given for a verb, such as providing a string
        to %d, the generated string will contain a description of the problem,
        as in these examples:
    
            Wrong type or unknown verb: %!verb(type=value)
                    Printf("%d", hi):          %!d(string=hi)
            Too many arguments: %!(EXTRA type=value)
                    Printf("hi", "guys"):      hi%!(EXTRA string=guys)
            Too few arguments: %!verb(MISSING)
                    Printf("hi%d"):            hi%!d(MISSING)
            Non-int for width or precision: %!(BADWIDTH) or %!(BADPREC)
                    Printf("%*s", 4.5, "hi"):  %!(BADWIDTH)hi
                    Printf("%.*s", 4.5, "hi"): %!(BADPREC)hi
            Invalid or invalid use of argument index: %!(BADINDEX)
                    Printf("%*[2]d", 7):       %!d(BADINDEX)
                    Printf("%.[2]d", 7):       %!d(BADINDEX)
    
        All errors begin with the string "%!" followed sometimes by a single
        character (the verb) and end with a parenthesized description.
    
        If an Error or String method triggers a panic when called by a print
        routine, the fmt package reformats the error message from the panic,
        decorating it with an indication that it came through the fmt package.
        For example, if a String method calls panic("bad"), the resulting
        formatted message will look like
    
            %!s(PANIC=bad)
    
        The %!s just shows the print verb in use when the failure occurred. If
        the panic is caused by a nil receiver to an Error or String method,
        however, the output is the undecorated string, "<nil>".
    
    
        Scanning
    
        An analogous set of functions scans formatted text to yield values.
        Scan, Scanf and Scanln read from os.Stdin; Fscan, Fscanf and Fscanln
        read from a specified io.Reader; Sscan, Sscanf and Sscanln read from an
        argument string.
    
        Scan, Fscan, Sscan treat newlines in the input as spaces.
    
        Scanln, Fscanln and Sscanln stop scanning at a newline and require that
        the items be followed by a newline or EOF.
    
        Scanf, Fscanf, and Sscanf parse the arguments according to a format
        string, analogous to that of Printf. In the text that follows, 'space'
        means any Unicode whitespace character except newline.
    
        In the format string, a verb introduced by the % character consumes and
        parses input; these verbs are described in more detail below. A
        character other than %, space, or newline in the format consumes exactly
        that input character, which must be present. A newline with zero or more
        spaces before it in the format string consumes zero or more spaces in
        the input followed by a single newline or the end of the input. A space
        following a newline in the format string consumes zero or more spaces in
        the input. Otherwise, any run of one or more spaces in the format string
        consumes as many spaces as possible in the input. Unless the run of
        spaces in the format string appears adjacent to a newline, the run must
        consume at least one space from the input or find the end of the input.
    
        The handling of spaces and newlines differs from that of C's scanf
        family: in C, newlines are treated as any other space, and it is never
        an error when a run of spaces in the format string finds no spaces to
        consume in the input.
    
        The verbs behave analogously to those of Printf. For example, %x will
        scan an integer as a hexadecimal number, and %v will scan the default
        representation format for the value. The Printf verbs %p and %T and the
        flags # and + are not implemented, and the verbs %e %E %f %F %g and %G
        are all equivalent and scan any floating-point or complex value.
    
        Input processed by verbs is implicitly space-delimited: the
        implementation of every verb except %c starts by discarding leading
        spaces from the remaining input, and the %s verb (and %v reading into a
        string) stops consuming input at the first space or newline character.
    
        The familiar base-setting prefixes 0 (octal) and 0x (hexadecimal) are
        accepted when scanning integers without a format or with the %v verb.
    
        Width is interpreted in the input text but there is no syntax for
        scanning with a precision (no %5.2f, just %5f). If width is provided, it
        applies after leading spaces are trimmed and specifies the maximum
        number of runes to read to satisfy the verb. For example,
    
            Sscanf(" 1234567 ", "%5s%d", &s, &i)
    
        will set s to "12345" and i to 67 while
    
            Sscanf(" 12 34 567 ", "%5s%d", &s, &i)
    
        will set s to "12" and i to 34.
    
        In all the scanning functions, a carriage return followed immediately by
        a newline is treated as a plain newline (\r\n means the same as \n).
    
        In all the scanning functions, if an operand implements method Scan
        (that is, it implements the Scanner interface) that method will be used
        to scan the text for that operand. Also, if the number of arguments
        scanned is less than the number of arguments provided, an error is
        returned.
    
        All arguments to be scanned must be either pointers to basic types or
        implementations of the Scanner interface.
    
        Like Scanf and Fscanf, Sscanf need not consume its entire input. There
        is no way to recover how much of the input string Sscanf used.
    
        Note: Fscan etc. can read one character (rune) past the input they
        return, which means that a loop calling a scan routine may skip some of
        the input. This is usually a problem only when there is no space between
        input values. If the reader provided to Fscan implements ReadRune, that
        method will be used to read characters. If the reader also implements
        UnreadRune, that method will be used to save the character and
        successive calls will not lose data. To attach ReadRune and UnreadRune
        methods to a reader without that capability, use bufio.NewReader.
    
    FUNCTIONS
    
    func Errorf(format string, a ...interface{}) error
        Errorf formats according to a format specifier and returns the string as
        a value that satisfies error.
    
    func Fprint(w io.Writer, a ...interface{}) (n int, err error)
        Fprint formats using the default formats for its operands and writes to
        w. Spaces are added between operands when neither is a string. It
        returns the number of bytes written and any write error encountered.
    
    func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
        Fprintf formats according to a format specifier and writes to w. It
        returns the number of bytes written and any write error encountered.
    
    func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
        Fprintln formats using the default formats for its operands and writes
        to w. Spaces are always added between operands and a newline is
        appended. It returns the number of bytes written and any write error
        encountered.
    
    func Fscan(r io.Reader, a ...interface{}) (n int, err error)
        Fscan scans text read from r, storing successive space-separated values
        into successive arguments. Newlines count as space. It returns the
        number of items successfully scanned. If that is less than the number of
        arguments, err will report why.
    
    func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
        Fscanf scans text read from r, storing successive space-separated values
        into successive arguments as determined by the format. It returns the
        number of items successfully parsed. Newlines in the input must match
        newlines in the format.
    
    func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
        Fscanln is similar to Fscan, but stops scanning at a newline and after
        the final item there must be a newline or EOF.
    
    func Print(a ...interface{}) (n int, err error)
        Print formats using the default formats for its operands and writes to
        standard output. Spaces are added between operands when neither is a
        string. It returns the number of bytes written and any write error
        encountered.
    
    func Printf(format string, a ...interface{}) (n int, err error)
        Printf formats according to a format specifier and writes to standard
        output. It returns the number of bytes written and any write error
        encountered.
    
    func Println(a ...interface{}) (n int, err error)
        Println formats using the default formats for its operands and writes to
        standard output. Spaces are always added between operands and a newline
        is appended. It returns the number of bytes written and any write error
        encountered.
    
    func Scan(a ...interface{}) (n int, err error)
        Scan scans text read from standard input, storing successive
        space-separated values into successive arguments. Newlines count as
        space. It returns the number of items successfully scanned. If that is
        less than the number of arguments, err will report why.
    
    func Scanf(format string, a ...interface{}) (n int, err error)
        Scanf scans text read from standard input, storing successive
        space-separated values into successive arguments as determined by the
        format. It returns the number of items successfully scanned. If that is
        less than the number of arguments, err will report why. Newlines in the
        input must match newlines in the format. The one exception: the verb %c
        always scans the next rune in the input, even if it is a space (or tab
        etc.) or newline.
    
    func Scanln(a ...interface{}) (n int, err error)
        Scanln is similar to Scan, but stops scanning at a newline and after the
        final item there must be a newline or EOF.
    
    func Sprint(a ...interface{}) string
        Sprint formats using the default formats for its operands and returns
        the resulting string. Spaces are added between operands when neither is
        a string.
    
    func Sprintf(format string, a ...interface{}) string
        Sprintf formats according to a format specifier and returns the
        resulting string.
    
    func Sprintln(a ...interface{}) string
        Sprintln formats using the default formats for its operands and returns
        the resulting string. Spaces are always added between operands and a
        newline is appended.
    
    func Sscan(str string, a ...interface{}) (n int, err error)
        Sscan scans the argument string, storing successive space-separated
        values into successive arguments. Newlines count as space. It returns
        the number of items successfully scanned. If that is less than the
        number of arguments, err will report why.
    
    func Sscanf(str string, format string, a ...interface{}) (n int, err error)
        Sscanf scans the argument string, storing successive space-separated
        values into successive arguments as determined by the format. It returns
        the number of items successfully parsed. Newlines in the input must
        match newlines in the format.
    
    func Sscanln(str string, a ...interface{}) (n int, err error)
        Sscanln is similar to Sscan, but stops scanning at a newline and after
        the final item there must be a newline or EOF.
    
    TYPES
    
    type Formatter interface {
        Format(f State, c rune)
    }
        Formatter is the interface implemented by values with a custom
        formatter. The implementation of Format may call Sprint(f) or Fprint(f)
        etc. to generate its output.
    
    type GoStringer interface {
        GoString() string
    }
        GoStringer is implemented by any value that has a GoString method, which
        defines the Go syntax for that value. The GoString method is used to
        print values passed as an operand to a %#v format.
    
    type ScanState interface {
        // ReadRune reads the next rune (Unicode code point) from the input.
        // If invoked during Scanln, Fscanln, or Sscanln, ReadRune() will
        // return EOF after returning the first '\n' or when reading beyond
        // the specified width.
        ReadRune() (r rune, size int, err error)
        // UnreadRune causes the next call to ReadRune to return the same rune.
        UnreadRune() error
        // SkipSpace skips space in the input. Newlines are treated appropriately
        // for the operation being performed; see the package documentation
        // for more information.
        SkipSpace()
        // Token skips space in the input if skipSpace is true, then returns the
        // run of Unicode code points c satisfying f(c).  If f is nil,
        // !unicode.IsSpace(c) is used; that is, the token will hold non-space
        // characters. Newlines are treated appropriately for the operation being
        // performed; see the package documentation for more information.
        // The returned slice points to shared data that may be overwritten
        // by the next call to Token, a call to a Scan function using the ScanState
        // as input, or when the calling Scan method returns.
        Token(skipSpace bool, f func(rune) bool) (token []byte, err error)
        // Width returns the value of the width option and whether it has been set.
        // The unit is Unicode code points.
        Width() (wid int, ok bool)
        // Because ReadRune is implemented by the interface, Read should never be
        // called by the scanning routines and a valid implementation of
        // ScanState may choose always to return an error from Read.
        Read(buf []byte) (n int, err error)
    }
        ScanState represents the scanner state passed to custom scanners.
        Scanners may do rune-at-a-time scanning or ask the ScanState to discover
        the next space-delimited token.
    
    type Scanner interface {
        Scan(state ScanState, verb rune) error
    }
        Scanner is implemented by any value that has a Scan method, which scans
        the input for the representation of a value and stores the result in the
        receiver, which must be a pointer to be useful. The Scan method is
        called for any argument to Scan, Scanf, or Scanln that implements it.
    
    type State interface {
        // Write is the function to call to emit formatted output to be printed.
        Write(b []byte) (n int, err error)
        // Width returns the value of the width option and whether it has been set.
        Width() (wid int, ok bool)
        // Precision returns the value of the precision option and whether it has been set.
        Precision() (prec int, ok bool)
    
        // Flag reports whether the flag c, a character, has been set.
        Flag(c int) bool
    }
        State represents the printer state passed to custom formatters. It
        provides access to the io.Writer interface plus information about the
        flags and options for the operand's format specifier.
    
    type Stringer interface {
        String() string
    }
        Stringer is implemented by any value that has a String method, which
        defines the ``native'' format for that value. The String method is used
        to print values passed as an operand to any format that accepts a string
        or to an unformatted printer such as Print.
    
    • 查看某个包中某个函数
    C:\Users\zhang>godoc fmt Println
    use 'godoc cmd/fmt' for documentation on the fmt command
    
    func Println(a ...interface{}) (n int, err error)
        Println formats using the default formats for its operands and writes to
        standard output. Spaces are always added between operands and a newline
        is appended. It returns the number of bytes written and any write error
        encountered.
    

    七.gofmt工具

    1.gofmt工具介绍

    • 规范的代码方便自己的阅读也方便别人的阅读.编写规范代码是每个程序的必修课
    • gofmt工具可以帮助程序员把代码进行格式化,按照规范进行格式化
    • 使用gofmt前提是文件编译通过

    2. 不规范代码示例

    • 查看下面代码中不规范的地方有几处
    package main
    import "fmt"
    func main ( ){
    fmt.Println("hello word");
    }
    

    3.使用gofmt的步骤

    • 在命令行输入gofmt 文件名就可以对文件进行格式化,格式化后输出
    D:\go\0201>gofmt main.go
    package main
    
    import "fmt"
    
    func main() {
            fmt.Println("hello word")
    }
    
    • 通过运行gofmt后发现规范的代码和不规范代码的几处区别
      • package关键字和import关键字和func main之间有空行
      • main和括号之间没有空格
      • main后面()之间没有空格
      • ()和{之间有空格
      • fmt.Println()前面有缩进
      • fmt.Println()后面没有分号

    ​ --作者:额滴神

    展开全文
  • All HTTP requests and responses are then encrypted with these session keys, so that anyone who intercepts communications can only see a random string of characters, not the plaintext. 所有的HTTP请求...

    HTTP requests and responses are sent in plaintext, which means that anyone can read them. 

    HTTP方式的请求和响应都是在明文下传输的,这就意味着任何人都可以读取它们的内容。

    HTTP与HTTPS比较,不同之处有哪些? HTTP vs. HTTPS: What are the differences?

    HTTPS is HTTP with encryption. The only difference between the two protocols is that HTTPS uses TLS (SSL) to encrypt normal HTTP requests and responses. As a result, HTTPS is far more secure than HTTP. A website that uses HTTP has http:// in its URL, while a website that uses HTTPS has https://.

    HTTPS方式是HTTP的方式上加上加密,唯一的区别就是HTTPS方式使用SSL/TLS对正常的HTTP请求和响应进行了加密。结果就是,HTTPS方式比HTTP更安全。使用HTTP方式访问的网站的URL前缀是http://,而相对的HTTPS的则是以https://开头。

     

    What is HTTP?

    HTTP stands for Hypertext Transfer Protocol, and it is a protocol – or a prescribed order and syntax for presenting information – used for transferring data over a network. Most information that is sent over the Internet, including website content and API calls, uses the HTTP protocol. There are two main kinds of HTTP messages: requests and responses.

    HTTP意为超文本传输协议,它是一个用于在网络上传输数据的协议,或一个根据预定顺序的一种语法,为的是传输展示信息的。大多数在网络上的数据是以HTTP方式传输,包括网站内容和API调用。HTTP有两种消息,请求和响应。

    In the OSI model, HTTP is a layer 7 protocol.

    在OSI模型中,HTTP拥有7层。

    什么是HTTP请求?什么是HTTP响应? What is an HTTP request? What is an HTTP response?

    HTTP requests are generated by a user's browser as the user interacts with web properties. For example, if a user clicks on a hyperlink, the browser will send a series of "HTTP GET" requests for the content that appears on that page. If someone Googles "What is HTTP?" and this article shows up in the search results, when they click on the link, their browser will create and send a series of HTTP requests in order to get the information necessary to render the page.

    HTTP请求是用户在于网络资源交互时通过用户的浏览器产生的,例如,如果用户点击了一个超链接,浏览器将会发过一系列HTTP的GET请求来请求将要在页面上展示的内容。如果用户使用Google搜索了”What is HTTP?",在结果页面有一个文章,当用户再点击这篇文章时,浏览器会创建并发送一系列的HTTP请求,为的是获取足够的信息来展示解析这个页面。

    These HTTP requests all go to either an origin server or a proxy caching server, and that server will generate an HTTP response. HTTP responses are answers to HTTP requests.

    这些HTTP请求要么指向资源的源服务器要么是代理缓存服务器,这些服务器会生成对应的HTTP响应。HTTP响应就是为了回复HTTP请求的。

    一个典型的HTTP请求长什么样? What does a typical HTTP request look like?

    An HTTP request is just a series of lines of text that follow the HTTP protocol. A GET request might look like this:

    HTTP请求就是一系列的遵守HTTP协议的文本行,一个GET请求示例如下:

    
    GET /hello.txt HTTP/1.1
    User-Agent: curl/7.63.0 libcurl/7.63.0 OpenSSL/1.1.l zlib/1.2.11
    Host: www.example.com
    Accept-Language: en
    

    This section of text, generated by the user's browser, gets sent across the Internet. The problem is, it's sent just like this, in plaintext that anyone monitoring the connection can read. (Those who are unfamiliar with the HTTP protocol may find this text hard to understand, but anyone with a baseline knowledge of the protocol's commands and syntax can read it easily.)

    上面的文本是被用户的浏览器生成的,可以通过网络发送出去。这问题就是,它就是这样以明文的形式发送出去,任何监测了连接的人都可以读取内容。(不熟悉HTTP协议的人可能会认为这些上述内容不好理解,但是任何有一些有关协议命令语法知识的人,都可以轻松的读取)

    This is especially an issue when users submit sensitive data via a website or a web application. This could be a password, a credit card number, or any other data entered into a form, and in HTTP all this data is sent in plaintext for anyone to read. (When a user submits a form, the browser translates this into an HTTP POST request instead of an HTTP GET request.)

    当用于通过网站或相关应用提交敏感数据时,这就是一个严重的问题了。这些敏感数据可能是一个密码,一个信用卡号,或者在表单中输入的数据,在用HTTP方式访问网站时,这些数据全部以明文方式传输,任何人都可以读取到。(当用户提交一个表单,浏览器使用HTTP的POST方法,而不是GET方法。)

    When an origin server receives an HTTP request, it sends an HTTP response, which is similar:

    当一个服务器收到HTTP请求后,它会回复一个HTTP响应,示例如下:

    
    HTTP/1.1 200 OK
    Date: Wed, 30 Jan 2019 12:14:39 GMT
    Server: Apache
    Last-Modified: Mon, 28 Jan 2019 11:17:01 GMT
    Accept-Ranges: bytes
    Content-Length: 12
    Vary: Accept-Encoding
    Content-Type: text/plain
    
    Hello World!
    

    If a website uses HTTP instead of HTTPS, all requests and responses can be read by anyone who is monitoring the session. Essentially, a malicious actor can just read the text in the request or the response and know exactly what information someone is asking for, sending, or receiving.

    如果一个网站使用HTTP而非HTTPS,那么所有的请求和响应,只要有人在监测连接,都能读取到这些内容。本质上来讲,任何一个有恶意的人都能从请求和响应中读到并晓得其他人在查询什么,发送什么和接收什么。 

     

    HTTPS是什么? What is HTTPS?

    The S in HTTPS stands for "secure." HTTPS uses TLS (or SSL) to encrypt HTTP requests and responses, so in the example above, instead of the text, an attacker would see a bunch of seemingly random characters.

    HTTPS中的S代表的是安全,HTTPS方式使用SSL/TLS去加密HTTP中的请求和响应数据,所以,在上面的例子中,攻击者会看到一堆看似随机的字符而不是明文。

    Instead of: HTTPS使用的不是下面这种

    
    GET /hello.txt HTTP/1.1
    User-Agent: curl/7.63.0 libcurl/7.63.0 OpenSSL/1.1.l zlib/1.2.11
    Host: www.example.com
    Accept-Language: en
    

    The attacker sees something like: 攻击者看到的东西是下面这样

    8Fw6T8UV81pQfyhDkhebbz7+oiwldr1j2gHBB3L3RFTRsQCpaSnSBZ78Vme+DpDVJPvZdZUZHpzbbcqmSW1+3xXGsERHg9YDmpYk0VVDiRvw1H5miNieJeJ/FNUjgH0BmVRWII6+T4MnDwmCMZUI/orxP3HGwYCSIvyzS3MpmmSe4iaWKCOHQ==

    HTTPS请求中,TLS/SSL是如何加密HTTP请求和响应的? In HTTPS, how does TLS/SSL encrypt HTTP requests and responses?

    TLS uses a technology called public key encryption: there are two keys, a public key and a private key, and the public key is shared with client devices via the server's SSL certificate. When a client opens a connection with a server, the two devices use the public and private key to agree on new keys, called session keys, to encrypt further communications between them.

    TLS使用了一种名为公钥加密术的加密方式,这种方式有两个密钥,就是公钥和私钥。而公钥则是随着服务器的SSL证书下发分享到客户端。当一个客户端连接到服务器时,他们使用公钥私钥来沟通之后交互使用的对称密钥,也称为会话密钥。

    All HTTP requests and responses are then encrypted with these session keys, so that anyone who intercepts communications can only see a random string of characters, not the plaintext.

    所有的HTTP请求与响应被会话密钥加密解密,所以再有人拦截,看到的也只会是一堆随机的字符,而不是之前的明文了。

    HTTPS如何对访问的服务器进行身份验证? How does HTTPS help authenticate web servers? 

    Authentication means verifying that a person or machine is who they claim to be. In HTTP, there is no verification of identity – it's based on a principle of trust. The architects of HTTP didn't necessarily make a decision to implicitly trust all web servers; they simply had priorities other than security at the time. But on the modern Internet, authentication is essential.

    身份验证就是验证一个人或一台机器是否是它们声明的那个身份。在HTTP请求中,完全没有这种验证机制,它更相当于基于信任的原则。HTTP的设计架构中,不是必需去显示决定要不要信任所有的网站服务器,访问通顺大于安全。但是在现代的互联网中,身份验证是必需的。

    Just like an ID card confirms a person's identity, a private key confirms server identity. When a client opens a channel with an origin server (e.g. when a user navigates to a website), possession of the private key that matches with the public key in a website's SSL certificate proves that the server is actually the legitimate host of the website. This prevents or helps block a number of attacks that are possible when there is no authentication, such as:

    就像身份证能证明一个人的身份那样,私钥用于确定服务器的身份。当一个客户端打开访问服务器的通道时,如使用导航栏地址栏打开一个网址,一旦网站的SSL证书的公钥和服务器拥有的私钥能够匹配时,就能证明要访问的服务器就是这个网站的合法主机,身份验证即可通过。这能防止或阻拦那种在没有身份验证机制中存在的大多数攻击,发:

    • On-path attacks 中间人攻击
    • DNS hijacking DNS劫持
    • BGP hijacking IP段支持 路由支持 等
    • Domain spoofing 域名欺诈

    展开全文
  • 1 语法树(parse tree): 是在parsing阶段,derivation的图像化表示,parser tree focus on grammar的actual implemment,包括像white spaces, braces, keywords, parenthesis 等一些细节。 “parse tree” 也叫 ...
  • 特殊疑问句: 特殊疑问句指的是用特殊疑问代词如:what(什么) 、where(哪里),who(谁),when(什么时候),why(为何),which(哪一个),how(如何)等所引导的疑问句。这种疑问句要求对方根据具体情况作出...
  • 英语基础语法

    千次阅读 多人点赞 2017-08-22 23:53:14
     Yes I am /no I am not Were they in the classroomyesterday? 回答同上 代词 主格:I , you, he, she, it, we, they 宾格:me, you, her, him, it, us, them Ex: they known him. 形容词性物主代词: your, my, ...
  • ) 语法形式上要一致,即单复数形式与谓语要一致。2) 意义上要一致,即主语意义上的单复数要与谓语的单复数形式一致。3) 就近原则,即谓语动词的单复形式取决于最靠近它的词语, 一般来说,不可数名词用动词单数,可...
  • 编程语言语法汇总 编程辅导 (PROGRAMMING TUTORIAL) We love to criticize programming languages. 我们喜欢批评编程语言。 We also love to quote Bjarne Stroustrup: 我们也喜欢引用Bjarne Stroustrup的话: ...
  • 我为什么不放弃博客园使用简书 Why I donot give up cnblogs for Jianshu Chapter0 从2016年8月开始接触简书开始,就有些喜欢上简书了,因为简书支持 markdown 语法,相比之下,博客园虽然也有一个支持 markdown ...
  • ") else: cthulhu_room() def dead(why): print why,"Good job!" exit(0) def start(): print"You are in a dark room." print"There is a door to your right and left." print"Which one do you take?" print"1....
  • 在计算机科学中,抽象语法和抽象语法树其实是源代码的抽象语法结构的树状表现形式我们可以用一个在线的AST编辑器来观察AST的构建Python语言的执行过程就是通过将Python字节码转化为抽象语法树来进行下一步的分析等...
  • 今天 用grunt 管理reactjs……打开项目,一路飘红……why……Preferences -> Languages and Frameworks -> JavaScript -> language version下拉框里选JSX Harmony : ) ——在 Languages & Frameworks &...
  • 语法填空

    2021-02-05 17:35:46
    语法是死的! 单词会不断重复! 高考英语语法填空 11大考点 语法报菜名 括号法 语法全景图 题目?考点 【语法填空满分路线图】 Step 1. 学会辉哥讲的11个考点 Step 2.在辉哥带领下见识这11个考点 Step 3. 看错题 ...
  • SQL UPDATE语法说明

    2020-07-26 16:51:20
    This can be tricky at first compared to joining stuff in a SELECT statement and it’s not always straightforward, but once you get familiar with the syntax it gets easier. 与将内容添加到SELECT语句中...
  • 大学英语语法总结

    千次阅读 2020-05-12 19:22:13
    总结了大学基本的语法,从谓语、非谓语、从句分为3大类,便于查看 (内容来源于网络,我又进行修改更简化的全面总结了语法知识) 大学英语语法总结谓语时态一般现在时一般过去时一般将来时现在进行时过去进行时进行...
  • 数组的Java泛型语法

    2021-07-16 23:45:18
    // Why does this satisfy the declaration? //someListArray[0] => ArrayList object holding Strings someListArray= getArrayWhereEachElementIsAListOfArrayListObjects(); //someListArray[0] => ArrayList ...
  • pocket英语语法入门

    千次阅读 2020-04-14 09:28:55
    what,how,如果疑问词是主语,那么其他语句依照陈述句语序不变,如果疑问词不是主语,需要借助系动词或者,另取一个助动词 第十讲,使用疑问词进行提问和回答 使用疑问词进行提问How far, how long, how often, why....
  • 语法

    2021-09-21 12:27:55
    I do not know whether he will cry I do not know why he cries 主语从句 That the earth is round has been known for years. Whether the earth is round has been known for years. Why the earth is round has...
  • 语法长难句(刘晓艳

    千次阅读 2020-12-26 10:53:58
    写作 1)所有写不了的长短句暂时都写成简单句,必须保证语法正确 2)所有不会写的单词都可以写成自己会的词汇,反正老师也不知道怎么要表达什么 2.长短句分析 1)找动词(谓语) 2)找主谓宾 如果一句话找到多个动词...
  • I am reading an article about python removing duplicate element in a list.there is a function defined as:def f8(seq): # Dave Kirby# Order preservingseen = set()return [x for x in seq if x not in seen ...
  • MySQL中的SQL语法错误

    2021-07-16 16:51:41
    $from = $_POST['from']; $to = $_POST['to'];... Why MySQL does not give a proper error for such terrible mistake? 解决方案`from`='$from', `to`='$to' FROM is reserved word use backtick around it.
  • pocket英语语法崔荣容笔记

    千次阅读 2021-06-23 09:42:12
    第8讲 实意动词的否定 提问 回答 使用助动词进行否定 在助动词do、does (一般现在时)、did(一般过去时) 后面加not do not / don’t does not / doesn’t did not / didn’t. l don’t go to school by bus. ( ...
  • 英语语法总结

    千次阅读 2019-08-03 19:31:25
    英语语法总结 第一部分:基础概念 1、词性 2、句子成分 3、构词法 第二部分:基础篇 1、词性一 名词 - 名词的分类 - 名词所有格 - 主谓一致 2、词性二 代词 - 代词的分类 - 3、词性三 ...
  • 【单选题】Why did Ben’s emotions change so much?【判断题】Write the title in the middle of the first line.【单选题】Six days before Christmas, Ben decided to give the woman the milk as a present ...
  • 表结构如下:create table test.t2(id int primary key not null,col int not null)engine=myisam default charset=gbk;如果执行下面的代码:insert into test.t2(id,col)values (1,1);由于id列为主键一定会报错。...
  • The reason why all the other suggested methods are not advisable is because they contain the characters ?> inside the PHP tag, which the XML parser will interpret as the...
  • I have just seen the following example in PEP 484:def greeting(name: str) -> str:return 'Hello ' + nameprint(greeting('Martin'))print(greeting(1))As expected, this does not work in Python 2:File "...
  • I don’t know why I did that. Perhaps it was nervousness, perhaps it was because, when you get very close, one to another, it is very hard not to smile. In any case, I smiled. In that instant, it was...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 15,231
精华内容 6,092
关键字:

not语法why