Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
gitgitcode
code
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
learnNote
Breadcrumbs
code
/
chapter2
/
sample
/
main.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
50 lines (43 loc) · 1.58 KB
learnNote
Breadcrumbs
code
/
chapter2
/
sample
/
main.go
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
50 lines (43 loc) · 1.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package
main
//main 函数保存在名为main的的包里
//不在 构建工具不会生成可执行的文件
//每个代码文件都属于一个包
//@一个包定义一组编译过的代码,包的名字类似命名空间,可以用来间接访问包内生命的标示符。
//@这个特性把不同的包中的同名标识符区分开
//-sample 外部目录
// -data
// data.json --数据源
// - matachers
// rss.go --搜索rss源的匹配器
// -search
// default.go --搜索默认匹配起
// feed.go --用于读取json数据的文件
// match.go --用于支持不同匹配器的接口
// search.go --执行搜索的主控制逻辑
// main.go -- 程序的入口
import
(
//import 导入一段代码
"log"
"os"
_
"github.com/goinaction/code/chapter2/sample/matchers"
//_ 下划线 为了让go对包进行初始化 但是并不使用包里的标识符
//因为不允许声明不使用 下划线 让编译器接收这类导入,
//并调用对应的包的init函数
//目的是调用matcher中的rss.go的init()函数
"github.com/goinaction/code/chapter2/sample/search"
)
//导入search 可以使用search中的run函数
//疑问🤔️ search里的init是声明时间执行的
// init is called prior to main.
//在main之前调用
//标准错误 stderr 标准输出stdout
func
init
() {
// Change the device for logging to stdout.
//将日志输出到标准输出
log
.
SetOutput
(
os
.
Stdout
)
}
// main is the entry point for the program.
//输口文件
func
main
() {
// Perform the search for the specified term.
//使用特定索索项目 search的run函数
search
.
Run
(
"president"
)
}
You can’t perform that action at this time.