Go 語言規范學習(1)

文章目錄

    • Introduction
    • Notation
        • 示例(Go 語言的 `if` 語句):
    • Source code representation
      • Characters
        • 例子:變量名可以是中文
      • Letters and digits
    • Lexical elements
      • Comments
      • Tokens
      • Semicolons
        • 例子:查看程序所有的token
      • Identifiers
      • Keywords
      • Operators and punctuation【運算符和標點符號】
      • Integer literals
      • Floating-point literals
      • Imaginary literals
      • Rune literals
      • String literals
    • Constants

Language version go1.24 (Dec 30, 2024)

Introduction

Go is a general-purpose language designed with systems programming in mind. It is strongly typed and garbage-collected and has explicit support for concurrent programming. Programs are constructed from packages, whose properties allow efficient management of dependencies.

The syntax is compact and simple to parse, allowing for easy analysis by automatic tools such as integrated development environments.

Notation

The syntax is specified using a variant of Extended Backus-Naur Form (EBNF):

Syntax      = { Production } .
Production  = production_name "=" [ Expression ] "." .
Expression  = Term { "|" Term } .
Term        = Factor { Factor } .
Factor      = production_name | token [ "…" token ] | Group | Option | Repetition .
Group       = "(" Expression ")" .
Option      = "[" Expression "]" .
Repetition  = "{" Expression "}" .

Productions are expressions constructed from terms and the following operators, in increasing precedence:

|   alternation
()  grouping
[]  option (0 or 1 times)
{}  repetition (0 to n times)

Lowercase production names are used to identify lexical (terminal【終結符】) tokens.

Non-terminals【非終結符】 are in CamelCase.

Lexical tokens are enclosed in double quotes "" or back quotes ````.


在形式語言理論(Formal Language Theory)和編譯原理中,產生式(Production) 是描述語言語法規則的表達式,它定義了如何從一個符號(非終結符)推導出其他符號(終結符或非終結符)的組合。產生式是 上下文無關文法(Context-Free Grammar, CFG) 的核心組成部分。

一個產生式通常寫成:

非終結符 = 符號序列 .

其中:

  • 非終結符(Non-terminal):表示語法結構的抽象概念(如 ExpressionStatement)。
  • 符號序列:由終結符(Token)或其他非終結符組成的序列。
  • . 表示產生式的結束。
示例(Go 語言的 if 語句):
IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .
  • IfStmt 是非終結符。
  • "if"";""else" 是終結符(Token)。
  • SimpleStmtExpressionBlock 是其他非終結符。

The form a … b represents the set of characters from a through b as alternatives.

The horizontal ellipsis is also used elsewhere in the spec to informally denote various enumerations or code snippets that are not further specified.

The character 【單個unicode字符】 (as opposed to the three characters ...) is not a token of the Go language.

Source code representation

Source code is Unicode text encoded in UTF-8. The text is not canonicalized, so a single accented code point is distinct from the same character constructed from combining an accent and a letter; those are treated as two code points. For simplicity, this document will use the unqualified term character to refer to a Unicode code point in the source text.


Go 不會對源代碼進行 Unicode 規范化(Canonicalization)。這意味著:

  • 組合字符序列(如 é 的兩種表示方式)會被視為不同的代碼點(Code Points):
    1. 單一代碼點éU+00E9,帶重音的拉丁小寫字母 e)
    2. 組合序列eU+0065) + ?U+0301,組合重音符號)
  • 雖然這兩種形式在顯示上相同,但 Go 會將其視為 兩個不同的字符序列

Each code point is distinct; for instance, uppercase and lowercase letters are different characters.

Implementation restriction: For compatibility with other tools, a compiler may disallow the NUL character (U+0000) in the source text.

Implementation restriction: For compatibility with other tools, a compiler may ignore a UTF-8-encoded byte order mark (U+FEFF) if it is the first Unicode code point in the source text. A byte order mark may be disallowed anywhere else in the source.

Characters

The following terms are used to denote specific Unicode character categories:

newline        = /* the Unicode code point U+000A */ .
unicode_char   = /* an arbitrary Unicode code point except newline */ .
unicode_letter = /* a Unicode code point categorized as "Letter" */ .
unicode_digit  = /* a Unicode code point categorized as "Number, decimal digit" */ .

In The Unicode Standard 8.0, Section 4.5 “General Category” defines a set of character categories. Go treats all characters in any of the Letter categories Lu, Ll, Lt, Lm, or Lo as Unicode letters, and those in the Number category Nd as Unicode digits.


Go 將以下 Unicode 字母類別的所有字符視為「字母」,可用于標識符(變量名、函數名等):

  • LuLetter, uppercase):大寫字母(如 A, Ω, Д
  • LlLetter, lowercase):小寫字母(如 a, ω, д
  • LtLetter, titlecase):標題字母(如某些連字字符的首字母形式,例如 ?
  • LmLetter, modifier):修飾字母(如上標字母 ?
  • LoLetter, other):其他字母(如漢字 、日文假名 、希伯來字母 ?

Go 僅將以下類別的字符視為「數字」:

  • NdNumber, decimal digit):十進制數字(如 0-9、阿拉伯數字 ?、中文數字 等)

例子:變量名可以是中文
package mainimport "fmt"var 名字 = "Go"  // 漢字(Lo)
const π = 3.14 // 希臘字母(Ll)
func Δx(x int) int { // 大寫希臘字母(Lu)return x + 1
}func main() {fmt.Println(Δx(2))
}

Letters and digits

The underscore character _ (U+005F) is considered a lowercase letter.

letter        = unicode_letter | "_" .
decimal_digit = "0" … "9" .
binary_digit  = "0" | "1" .
octal_digit   = "0" … "7" .
hex_digit     = "0" … "9" | "A" … "F" | "a" … "f" .

Lexical elements

Comments

Comments serve as program documentation. There are two forms:

  1. Line comments start with the character sequence // and stop at the end of the line.
  2. General comments start with the character sequence /* and stop with the first subsequent character sequence */.

A comment cannot start inside a rune or string literal, or inside a comment.

A general comment containing no newlines acts like a space. Any other comment acts like a newline.

Tokens

Tokens form the vocabulary of the Go language. There are four classes: identifiers, keywords, operators and punctuation, and literals. 【標識符,關鍵字,運算符和標點符號,字面值】

White space, formed from spaces (U+0020), horizontal tabs (U+0009), carriage returns (U+000D), and newlines (U+000A), is ignored except as it separates tokens that would otherwise combine into a single token.

Also, a newline or end of file may trigger the insertion of a semicolon.

While breaking the input into tokens, the next token is the longest sequence of characters that form a valid token.

Semicolons

The formal syntax uses semicolons ";" as terminators in a number of productions. Go programs may omit most of these semicolons using the following two rules:

  1. When the input is broken into tokens, a semicolon is automatically inserted into the token stream immediately after a line’s final token if that token is
    • an identifier
    • an integer, floating-point, imaginary, rune, or string literal
    • one of the keywords break, continue, fallthrough, or return
    • one of the operators and punctuation ++, --, ), ], or }
  2. To allow complex statements to occupy a single line, a semicolon may be omitted before a closing ")" or "}".

To reflect idiomatic use, code examples in this document elide semicolons using these rules.

例子:查看程序所有的token
package mainimport ("fmt""go/scanner""go/token"
)func main() {src := []byte(`
package mainimport "fmt"func main() {s := "Hello, tokens!"fmt.Println(s)
}
`)// 初始化 scannerfset := token.NewFileSet()file := fset.AddFile("example.go", fset.Base(), len(src))var s scanner.Scanners.Init(file, src, nil, scanner.ScanComments)// 掃描 tokensfor {pos, tok, lit := s.Scan()if tok == token.EOF {break}fmt.Printf("%-10s %-15s %q\n", fset.Position(pos), tok, lit)}
}

輸出

example.go:2:1 package         "package"
example.go:2:9 IDENT           "main"
example.go:2:13 ;               "\n"
example.go:4:1 import          "import"
example.go:4:8 STRING          "\"fmt\""
example.go:4:13 ;               "\n"
example.go:6:1 func            "func"
example.go:6:6 IDENT           "main"
example.go:6:10 (               ""
example.go:6:11 )               ""
example.go:6:13 {               ""
example.go:7:2 IDENT           "s"
example.go:7:4 :=              ""
example.go:7:7 STRING          "\"Hello, tokens!\""
example.go:7:23 ;               "\n"
example.go:8:2 IDENT           "fmt"
example.go:8:5 .               ""
example.go:8:6 IDENT           "Println"
example.go:8:13 (               ""
example.go:8:14 IDENT           "s"
example.go:8:15 )               ""
example.go:8:16 ;               "\n"
example.go:9:1 }               ""
example.go:9:2 ;               "\n"

Identifiers

Identifiers name program entities such as variables and types. An identifier is a sequence of one or more letters and digits. The first character in an identifier must be a letter.

identifier = letter { letter | unicode_digit } .
a
_x9
ThisVariableIsExported
αβ

Some identifiers are predeclared.

預先聲明的標識符如下:

Types:any bool byte comparablecomplex64 complex128 error float32 float64int int8 int16 int32 int64 rune stringuint uint8 uint16 uint32 uint64 uintptrConstants:true false iotaZero value:nilFunctions:append cap clear close complex copy delete imag lenmake max min new panic print println real recover

Keywords

The following keywords are reserved and may not be used as identifiers.

break        default      func         interface    select
case         defer        go           map          struct
chan         else         goto         package      switch
const        fallthrough  if           range        type
continue     for          import       return       var

Operators and punctuation【運算符和標點符號】

The following character sequences represent operators (including assignment operators) and punctuation [Go 1.18]:

+    &     +=    &=     &&    ==    !=    (    )
-    |     -=    |=     ||    <     <=    [    ]
*    ^     *=    ^=     <-    >     >=    {    }
/    <<    /=    <<=    ++    =     :=    ,    ;
%    >>    %=    >>=    --    !     ...   .    :&^          &^=          ~

Integer literals

An integer literal is a sequence of digits representing an integer constant.

An optional prefix sets a non-decimal base: 0b or 0B for binary【二進制】, 0, 0o, or 0O for octal【八進制】, and 0x or 0X for hexadecimal 【十六進制】[Go 1.13].

A single 0 is considered a decimal【十進制】 zero.

In hexadecimal literals, letters a through f and A through F represent values 10 through 15.

For readability, an underscore character _ may appear after a base prefix or between successive digits; such underscores do not change the literal’s value.

int_lit        = decimal_lit | binary_lit | octal_lit | hex_lit .
decimal_lit    = "0" | ( "1" … "9" ) [ [ "_" ] decimal_digits ] .
binary_lit     = "0" ( "b" | "B" ) [ "_" ] binary_digits .
octal_lit      = "0" [ "o" | "O" ] [ "_" ] octal_digits .
hex_lit        = "0" ( "x" | "X" ) [ "_" ] hex_digits .decimal_digits = decimal_digit { [ "_" ] decimal_digit } .
binary_digits  = binary_digit { [ "_" ] binary_digit } .
octal_digits   = octal_digit { [ "_" ] octal_digit } .
hex_digits     = hex_digit { [ "_" ] hex_digit } .
42
4_2
0600
0_600
0o600
0O600       // second character is capital letter 'O'
0xBadFace
0xBad_Face
0x_67_7a_2f_cc_40_c6
170141183460469231731687303715884105727
170_141183_460469_231731_687303_715884_105727_42         // an identifier, not an integer literal
42_         // invalid: _ must separate successive digits
4__2        // invalid: only one _ at a time
0_xBadFace  // invalid: _ must separate successive digits

Floating-point literals

A floating-point literal is a decimal or hexadecimal representation of a floating-point constant.

A decimal floating-point literal consists of an integer part 【整數部分】(decimal digits), a decimal point【小數點】, a fractional part 【小數部分】(decimal digits), and an exponent part【指數部分】 (e or E followed by an optional sign and decimal digits).

One of the integer part or the fractional part may be elided; one of the decimal point or the exponent part may be elided. An exponent value exp scales the mantissa【尾數】 (integer and fractional part) by 10exp.

A hexadecimal floating-point literal consists of a 0x or 0X prefix, an integer part (hexadecimal digits), a radix point【基數點。在 任意進制(如二進制、八進制、十六進制)的浮點數中,用于分隔整數部分和小數部分的點符號 .】, a fractional part (hexadecimal digits), and an exponent part (p or P followed by an optional sign and decimal digits).

One of the integer part or the fractional part may be elided; the radix point may be elided as well, but the exponent part is required. (This syntax matches the one given in IEEE 754-2008 §5.12.3.) An exponent value exp scales the mantissa (integer and fractional part) by 2exp [Go 1.13].

For readability, an underscore character _ may appear after a base prefix or between successive digits; such underscores do not change the literal value.

float_lit         = decimal_float_lit | hex_float_lit .decimal_float_lit = decimal_digits "." [ decimal_digits ] [ decimal_exponent ] |decimal_digits decimal_exponent |"." decimal_digits [ decimal_exponent ] .
decimal_exponent  = ( "e" | "E" ) [ "+" | "-" ] decimal_digits .hex_float_lit     = "0" ( "x" | "X" ) hex_mantissa hex_exponent .
hex_mantissa      = [ "_" ] hex_digits "." [ hex_digits ] |[ "_" ] hex_digits |"." hex_digits .
hex_exponent      = ( "p" | "P" ) [ "+" | "-" ] decimal_digits .
0.
72.40
072.40       // == 72.40
2.71828
1.e+0
6.67428e-11
1E6
.25
.12345E+5
1_5.         // == 15.0
0.15e+0_2    // == 15.00x1p-2       // == 0.25
0x2.p10      // == 2048.0
0x1.Fp+0     // == 1.9375
0X.8p-0      // == 0.5
0X_1FFFP-16  // == 0.1249847412109375
0x15e-2      // == 0x15e - 2 (integer subtraction)0x.p1        // invalid: mantissa has no digits
1p-2         // invalid: p exponent requires hexadecimal mantissa
0x1.5e-2     // invalid: hexadecimal mantissa requires p exponent
1_.5         // invalid: _ must separate successive digits
1._5         // invalid: _ must separate successive digits
1.5_e1       // invalid: _ must separate successive digits
1.5e_1       // invalid: _ must separate successive digits
1.5e1_       // invalid: _ must separate successive digits

Imaginary literals

An imaginary literal represents the imaginary part【虛部】 of a complex constant. It consists of an integer or floating-point literal followed by the lowercase letter i. The value of an imaginary literal is the value of the respective integer or floating-point literal multiplied by the imaginary unit i [Go 1.13]

imaginary_lit = (decimal_digits | int_lit | float_lit) "i" .

For backward compatibility, an imaginary literal’s integer part consisting entirely of decimal digits (and possibly underscores) is considered a decimal integer, even if it starts with a leading 0.

0i
0123i         // == 123i for backward-compatibility
0o123i        // == 0o123 * 1i == 83i
0xabci        // == 0xabc * 1i == 2748i
0.i
2.71828i
1.e+0i
6.67428e-11i
1E6i
.25i
.12345E+5i
0x1p-2i       // == 0x1p-2 * 1i == 0.25i

Rune literals

A rune literal represents a rune constant, an integer value identifying a Unicode code point. A rune literal is expressed as one or more characters enclosed in single quotes, as in 'x' or '\n'.

Within the quotes, any character may appear except newline and unescaped single quote. A single quoted character represents the Unicode value of the character itself, while multi-character sequences beginning with a backslash encode values in various formats.

The simplest form represents the single character within the quotes; since Go source text is Unicode characters encoded in UTF-8, multiple UTF-8-encoded bytes may represent a single integer value. For instance, the literal 'a' holds a single byte representing a literal a, Unicode U+0061, value 0x61, while '?' holds two bytes (0xc3 0xa4) representing a literal a-dieresis, U+00E4, value 0xe4.

Several backslash escapes allow arbitrary values to be encoded as ASCII text. There are four ways to represent the integer value as a numeric constant: \x followed by exactly two hexadecimal digits; \u followed by exactly four hexadecimal digits; \U followed by exactly eight hexadecimal digits, and a plain backslash \ followed by exactly three octal digits. In each case the value of the literal is the value represented by the digits in the corresponding base.

Although these representations all result in an integer, they have different valid ranges. Octal escapes must represent a value between 0 and 255 inclusive. Hexadecimal escapes satisfy this condition by construction. The escapes \u and \U represent Unicode code points so within them some values are illegal, in particular those above 0x10FFFF and surrogate halves.

After a backslash, certain single-character escapes represent special values:

\a   U+0007 alert or bell
\b   U+0008 backspace
\f   U+000C form feed
\n   U+000A line feed or newline
\r   U+000D carriage return
\t   U+0009 horizontal tab
\v   U+000B vertical tab
\\   U+005C backslash
\'   U+0027 single quote  (valid escape only within rune literals)
\"   U+0022 double quote  (valid escape only within string literals)

An unrecognized character following a backslash in a rune literal is illegal.

rune_lit         = "'" ( unicode_value | byte_value ) "'" .
unicode_value    = unicode_char | little_u_value | big_u_value | escaped_char .
byte_value       = octal_byte_value | hex_byte_value .
octal_byte_value = `\` octal_digit octal_digit octal_digit .
hex_byte_value   = `\` "x" hex_digit hex_digit .
little_u_value   = `\` "u" hex_digit hex_digit hex_digit hex_digit .
big_u_value      = `\` "U" hex_digit hex_digit hex_digit hex_digithex_digit hex_digit hex_digit hex_digit .
escaped_char     = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) .
'a'
'?'
'本'
'\t'
'\000'
'\007'
'\377'
'\x07'
'\xff'
'\u12e4'
'\U00101234'
'\''         // rune literal containing single quote character
'aa'         // illegal: too many characters
'\k'         // illegal: k is not recognized after a backslash
'\xa'        // illegal: too few hexadecimal digits
'\0'         // illegal: too few octal digits
'\400'       // illegal: octal value over 255
'\uDFFF'     // illegal: surrogate half
'\U00110000' // illegal: invalid Unicode code point

String literals

A string literal represents a string constant obtained from concatenating a sequence of characters.

There are two forms: raw string literals and interpreted string literals.

Raw string literals are character sequences between back quotes【反引號】 as in `foo`. Within the quotes, any character may appear except back quote. The value of a raw string literal is the string composed of the uninterpreted (implicitly UTF-8-encoded) characters between the quotes; in particular, backslashes have no special meaning and the string may contain newlines. Carriage return characters (‘\r’) inside raw string literals are discarded from the raw string value.

Interpreted string literals are character sequences between double quotes【雙引號】, as in "bar". Within the quotes, any character may appear except newline and unescaped double quote. The text between the quotes forms the value of the literal, with backslash escapes interpreted as they are in rune literals (except that \' is illegal and \" is legal), with the same restrictions. The three-digit octal (\nnn) and two-digit hexadecimal (\xnn) escapes represent individual bytes of the resulting string; all other escapes represent the (possibly multi-byte) UTF-8 encoding of individual characters. Thus inside a string literal \377 and \xFF represent a single byte of value 0xFF=255, while ?, \u00FF, \U000000FF and \xc3\xbf represent the two bytes 0xc3 0xbf of the UTF-8 encoding of character U+00FF.

string_lit             = raw_string_lit | interpreted_string_lit .
raw_string_lit         = "`" { unicode_char | newline } "`" .
interpreted_string_lit = `"` { unicode_value | byte_value } `"` .
`abc`                // same as "abc"
`\n
\n`                  // same as "\\n\n\\n"
"\n"
"\""                 // same as `"`
"Hello, world!\n"
"日本語"
"\u65e5本\U00008a9e"
"\xff\u00FF"
"\uD800"             // illegal: surrogate half
"\U00110000"         // illegal: invalid Unicode code point

These examples all represent the same string:

"日本語"                                 // UTF-8 input text
`日本語`                                 // UTF-8 input text as a raw literal
"\u65e5\u672c\u8a9e"                    // the explicit Unicode code points
"\U000065e5\U0000672c\U00008a9e"        // the explicit Unicode code points
"\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"  // the explicit UTF-8 bytes

If the source code represents a character as two code points, such as a combining form involving an accent and a letter, the result will be an error if placed in a rune literal (it is not a single code point), and will appear as two code points if placed in a string literal.

Constants

There are boolean constants, rune constants, integer constants, floating-point constants, complex constants, and string constants.

Rune, integer, floating-point, and complex constants are collectively called numeric constants.

A constant value is represented by a rune, integer, floating-point, imaginary, or string literal, an identifier denoting a constant, a constant expression, a conversion with a result that is a constant, or the result value of some built-in functions such as min or max applied to constant arguments, unsafe.Sizeof applied to certain values, cap or len applied to some expressions, real and imag applied to a complex constant and complex applied to numeric constants.

The boolean truth values are represented by the predeclared constants true and false. The predeclared identifier iota denotes an integer constant.

In general, complex constants are a form of constant expression and are discussed in that section.

Numeric constants represent exact values of arbitrary precision and do not overflow. Consequently, there are no constants denoting the IEEE 754 negative zero, infinity, and not-a-number values.


在 Go 語言中,數值常量(Numeric Constants) 的設計非常獨特,與其他編程語言(如 C、Java)中的常量或變量有本質區別。

1. 任意精度(Arbitrary Precision)

  • 無限精度計算
    Go 的數值常量在編譯時不受固定位數(如 32/64 位)限制,可以表示任意大的整數或任意小的小數,只要代碼能寫出來(受限于源碼長度)。
  • 精確無舍入
    計算過程中不會丟失精度(不像浮點數有 IEEE 754 舍入誤差)。

2. 不會溢出(No Overflow)

  • 自動擴展表示范圍
    編譯器會動態調整常量的存儲方式,確保計算時永遠不會溢出(直到內存耗盡)。

Constants may be typed or untyped. 【有類型的常量和無類型的常量】

Literal constants, true, false, iota, and certain constant expressions containing only untyped constant operands are untyped.

A constant may be given a type explicitly by a constant declaration or conversion, or implicitly when used in a variable declaration or an assignment statement or as an operand in an expression. It is an error if the constant value cannot be represented as a value of the respective type. If the type is a type parameter, the constant is converted into a non-constant value of the type parameter.

An untyped constant has a default type which is the type to which the constant is implicitly converted in contexts where a typed value is required, for instance, in a short variable declaration such as i := 0 where there is no explicit type. The default type of an untyped constant is bool, rune, int, float64, complex128, or string respectively, depending on whether it is a boolean, rune, integer, floating-point, complex, or string constant.

Implementation restriction: Although numeric constants have arbitrary precision in the language, a compiler may implement them using an internal representation with limited precision. That said, every implementation must:

  • Represent integer constants with at least 256 bits.
  • Represent floating-point constants, including the parts of a complex constant, with a mantissa of at least 256 bits and a signed binary exponent of at least 16 bits.
  • Give an error if unable to represent an integer constant precisely.
  • Give an error if unable to represent a floating-point or complex constant due to overflow.
  • Round to the nearest representable constant if unable to represent a floating-point or complex constant due to limits on precision.

These requirements apply both to literal constants and to the result of evaluating constant expressions.

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/74648.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/74648.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/74648.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

探索抓包利器ProxyPin,實現手機APP請求抓包,支持https請求

以下是ProxyPin的簡單介紹&#xff1a; - ProxyPin是一個開源免費HTTP(S)流量捕獲神器&#xff0c;支持 Windows、Mac、Android、IOS、Linux 全平臺系統- 可以使用它來攔截、檢查并重寫HTTP(S)流量&#xff0c;支持捕獲各種應用的網絡請求。ProxyPin基于Flutter開發&#xff0…

深度學習3-pytorch學習

深度學習3-pytorch學習 Tensor 定義與 PyTorch 操作 1. Tensor 定義&#xff1a; Tensor 是 PyTorch 中的數據結構&#xff0c;類似于 NumPy 數組。可以通過不同方式創建 tensor 對象&#xff1a; import torch# 定義一個 1D Tensor x1 torch.Tensor([3, 4])# 定義一個 Fl…

深入淺出Spring-Boot-3.x.pdf

通過網盤分享的文件&#xff1a;深入淺出Spring-Boot-3.x.pdf 鏈接: https://pan.baidu.com/s/10ZkhmeIXphEwND9Rv4EBlg?pwduatm 提取碼: uatm

springboot啟動事件CommandLineRunner使用

什么是CommandRunner CommandRunner是springboot啟動完成時會調用的一個runner 啟動參數會傳遞到這個runner 我們能用來做一些初始化工作和緩存預熱等工作 ApplicationRunner VS CommandRunner? 這兩個Runner作用一樣 只是得到的啟動參數格式不一樣 前者是一個Argument對象…

數據可視化TensorboardX和tensorBoard安裝及使用

tensorBoard 和TensorboardX 安裝及使用指南 tensorBoard 和 TensorBoardX 是用于可視化機器學習實驗和模型訓練過程的工具。TensorBoard 是 TensorFlow 官方提供的可視化工具&#xff0c;而 TensorBoardX 是其社區驅動的替代品&#xff0c;支持 PyTorch 等其他框架。以下是它…

藍橋杯C++基礎算法-多重背包

這段代碼實現了一個多重背包問題的動態規劃解法。多重背包問題與完全背包問題類似&#xff0c;但每個物品有其數量限制。以下是代碼的詳細思路解析&#xff1a; 1. 問題背景 給定 n 個物品&#xff0c;每個物品有其體積 v[i]、價值 w[i] 和數量 s[i]&#xff0c;以及一個容量為…

【SUNO】【AI作詞】【提示詞】

仿寫歌詞提示詞模板&#xff08;升級版&#xff09; 一、仿寫目標 風格定位 音樂風格&#xff1a; [填寫目標風格&#xff0c;如&#xff1a;民謠/流行/古風/電子/爵士等]參考案例&#xff1a;如《成都》的敘事民謠&#xff0c;《孤勇者》的勵志流行。 情感基調&#xff1a; […

26考研——樹與二叉樹_樹與二叉樹的應用(5)

408答疑 文章目錄 三、樹與二叉樹的應用哈夫曼樹和哈夫曼編碼哈夫曼樹的定義概念帶權路徑長度&#xff08;WPL&#xff09;計算示例分析 哈夫曼樹的構造算法描述哈夫曼樹的性質示例 哈夫曼編碼Huffman樹的編碼規則Huffman樹的構建過程前綴編碼前綴編碼的分析及應用 Huffman樹的…

【VUE】day06 動態組件 插槽 自定義指令 ESlint

【VUE】day06 動態組件 & 插槽 & 自定義指令 1. 動態組件1.1 通過不同的按鈕展示不同的組件1.1.1回顧click 1.2 keep-alive的使用1.3 keep-alive對應的生命周期函數1.3.1 keep-alive的include屬性1.3.2 exclude 1.4 組件注冊名稱和組件聲明時name的區別1.4.1 組件聲明時…

nodejs-原型污染鏈

還是老規矩&#xff0c;邊寫邊學&#xff0c;先分享兩篇文章 深入理解 JavaScript Prototype 污染攻擊 | 離別歌 《JavaScript百煉成仙》 全書知識點整理-CSDN博客 Ctfshow web入門 nodejs篇 web334-web344_web334 ctfshow-CSDN博客 334-js審計 var express require(expr…

Oracle 數據庫通過exp/imp工具遷移指定數據表

項目需求&#xff1a;從prod數據庫遷移和復制2個表(BANK_STATE&#xff0c;HBS)的數據到uat數據庫環境。 數據庫版本&#xff1a;Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 遷移工具&#xff1a;客戶端exp/imp工具 -- 執行命令 從Prod數據庫導出數據exp us…

企業級基于SpringBoot的MQTT的構建和使用

基于SpringBoot的MQTT配置及使用 首先要使用EMQX搭建一個MQTT服務器&#xff0c;參考文檔&#xff1a;EMQX快速開始 本著開源分享的觀點&#xff0c;閑話不多說&#xff0c;直接上代碼 導入Maven <dependency><groupId>org.springframework.integration</gro…

26考研——圖_圖的代碼實操(6)

408答疑 文章目錄 五、圖的代碼實操圖的存儲鄰接矩陣結構定義初始化插入頂點獲取頂點位置在頂點 v1 和 v2 之間插入邊獲取第一個鄰接頂點獲取下一個鄰接頂點顯示圖 鄰接表結構定義初始化圖插入頂點獲取頂點位置在頂點 v1 和 v2 之間插入邊獲取第一個鄰接頂點獲取下一個鄰接頂點…

開源webmail郵箱客戶端rainloop的分支版本SnappyMail 設置發件人允許多重身份

RainLoop已多年未更新&#xff0c;SnappyMail 是 RainLoop 的分支&#xff0c;由社區維護。SnappyMail 不僅修復了漏洞&#xff0c;還增加了更多功能和優化。對 IMAP 支持更好&#xff0c;移動端體驗也比 RainLoop 更細致。 安裝過程和設置跟RainLoop一樣&#xff1a; 以寶塔面…

海量數據場景題--查找兩個大文件的URL

查找兩個大文件共同的URL 給定 a、b 兩個文件&#xff0c;各存放 50 億個 URL&#xff0c;每個 URL 各占 64B&#xff0c;找出 a、b 兩個文件共同的 URL。內存限制是 4G。 操作邏輯&#xff1a; 使用哈希函數 hash(URL) % 1000? 將每個URL映射到0-999的編號 文件A切割為a0, a1…

簡單ELK框架搭建

簡介 ELK 框架是一套開源的日志管理和分析工具&#xff0c;由 Elasticsearch、Logstash 和 Kibana 三個主要組件組成&#xff0c;現在新增了Filebeat組件&#xff0c;可以更高效的收集數據。 Elasticsearch&#xff1a;是一個分布式、高可擴展的開源搜索引擎&#xff0c;能快速…

VS Code 中 .history`文件的來源與 .gitignore`的正確使用

引言 在使用 VS Code 進行 Git 版本控制時&#xff0c;有時會發現項目中多出一個 .history 目錄&#xff0c;并被 Git 識別為未跟蹤文件。本文將解釋 .history 的來源&#xff0c;并提供 .gitignore 的正確配置方法&#xff0c;確保開發環境的整潔性。 1. .history 文件的來源…

網絡之數據鏈路層

數據鏈路層 數據鏈路層目標 TCP/IP提供了一種能力, 將數據可靠的從 B 跨網絡送到 C 主機, 這期間是由無數次局域網轉發構成的, 比如 主機B 到 路由器F 就是一次局域網通信的問題, 而數據鏈路層就是研究數據是如何在局域網內部轉發的. 也就是說, 應用層是進行數據的處理, 傳輸…

A Brief History: from GPT-1 to GPT-3

This is my reading notes of 《Developing Apps with GPT-4 and ChatGPT》. In this section, we will introduce the evolution of the OpenAI GPT medels from GPT-1 to GPT-4. GPT-1 In mid-2018, OpenAI published a paper titled “Improving Language Understanding …

基于大數據的各品牌手機銷量數據可視化分析系統(源碼+lw+部署文檔+講解),源碼可白嫖!

摘要 時代在飛速進步&#xff0c;每個行業都在努力發展現在先進技術&#xff0c;通過這些先進的技術來提高自己的水平和優勢&#xff0c;各品牌手機銷量數據可視化分析系統當然不能排除在外。基于大數據的各品牌手機銷量數據可視化分析系統是在實際應用和軟件工程的開發原理之…