在函数外部使用形如:name:="mark"这样语句会出现 syntax error: non-declaration statement outside function body

package main

import "fmt"

var age uint8  // ok
var age1 uint8 = 18 // ok
var age2 = 18 // ok
age3 := 18 // error
// 出错的原因在于 age3 := 18实际上是两条语句 var age3 int + age3 = 18
// 然而age3 = 18这样的语句是不能再函数体之外执行的
// 就行下面两行代码
ag1 = 29 // error
age2 = 21 // error func main() {
fmt.Println("...")
}

syntax error: non-declaration statement outside function body的更多相关文章

  1. Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in

    学习php的命名空间,直接把手册的代码粘贴过来,却报错了:Fatal error: Namespace declaration statement has to be the very first s ...

  2. [ThinkPHP]报错:Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in E:\wamp\www\jdlh\application\index\controller\Index.php on line

    错误提示说命名空间声明语句必须是第一句,可我看就是第一句没毛病呀,这是为啥呢,后面发现<?php 前面有个空格,删掉就正常了 去掉空格之后页面能正常显示

  3. JS function document.onclick(){}报错Syntax error on token "function", delete this token

    JS function document.onclick(){}报错Syntax error on token "function", delete this token func ...

  4. JSP报错Syntax error, insert ";" to complete Statement

    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 7 in ...

  5. error: expected declaration or statement at end of input----solved

    error: expected declaration or statement at end of input 解决方法: 1.程序缺少一个括号相应地 2.而不添加头文件 版权声明:本文博主原创文章 ...

  6. JS function document.onclick(){}报错Syntax error on token "function", delete this token - CSDN博客

    原文:JS function document.onclick(){}报错Syntax error on token "function", delete this token - ...

  7. Linux下docker报错syntax error:unexpected protocol at end of statement

    ---恢复内容开始--- [Linux]Shell脚本“syntax error: unexpected end of file”原因及处理 :::https://blog.csdn.net/u013 ...

  8. HiveServer2 的jdbc方式创建udf的修改(add jar 最好不要使用),否则会造成异常: java.sql.SQLException: Error while processing statement: null

    自从Hive0.13.0开始,使用HiveServer2 的jdbc方式创建udf的临时函数的方法由: ADD JAR ${HiveUDFJarPath} create TEMPORARY funct ...

  9. php出现“syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM”错误的一种情况,及解决方法

    PHP中的“syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM”错误,可能是因为美元符号$的误用,看下面一种情况 class Test{         s ...

随机推荐

  1. qt cout输出中文乱码解决记录

    工具 -> 选项-> 文本编辑器-> 行为 -> 文件编码->默认编码改为System 乱码原因: 默认用utf-8编码,控制台默认gbk编码,编码不一致导致的乱码

  2. Zabbix部署-LNMP环境

    原文发表于cu:2016-05-05 参考文档: LNMP安装:http://www.osyunwei.com/archives/7891.html 一.环境 Server:CentOS-7-x86_ ...

  3. Python数据挖掘——数据概述

    Python数据挖掘——数据概述 数据集由数据对象组成: 数据的基本统计描述 中心趋势度量 均值 中位数 众数 中列数 数据集的最大值和最小值的平均 度量数据分布 极差 最大值与最小值的差 四分位数 ...

  4. SST:Single-Stream Temporal Action Proposals论文笔记

    SST:Single-Stream Temporal Action Proposals 这是本仙女认认真真读完且把算法全部读懂(其实也不是非常懂)的第一篇论文 CVPR2017 一作 论文写作的动机m ...

  5. 转:为什么说招到合适的人比融到钱更加重要 - Hiring Great Talent is More Important Than Fund Raising

    我在猎头行业工作了 20 多年,一直在帮助创业公司招聘优秀的人才.我服务过的客户既有 VC 投资的初创企业,也有即将 IPO 的公司.我和 200 多个 VC 合作过,也见过 300 多个客户失败的案 ...

  6. 3.Airflow使用

    1. airflow简介2. 相关概念2.1 服务进程2.1.1. web server2.1.2. scheduler2.1.3. worker2.1.4. celery flower2.2 相关概 ...

  7. python request 获取cookies value值的方法

    import requests res = requests.get(url) cookies = requests.utils.dict_from_cookiejar(res.cookies) pr ...

  8. 如何理解IPD+CMMI+Scrum一体化研发管理解决方案之Scrum篇

    如何快速响应市场的变化,如何推出更有竞争力的产品,如何在竞争中脱颖而出,是国内研发企业普遍面临的核心问题,为了解决这些问题,越来越多的企业开始重视创新与研发管理,加强研发过程的规范化,集成产品开发(I ...

  9. LeetCode 206. Reverse Linked List(C++)

    题目: Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4 ...

  10. 《C》数组

    数组 数组方法: var arr = [1, 2, 3]; arr.push(4)://arr='[1, 2, 3, 4]' 向末尾添加一个或者多个元素 arr.pop()://删除末位元素 var ...