Print All Structures in a Golang Package

The program is designed to traverse and analyze Go language source code within a specified package directory. It utilizes the go/parser and go/token packages to parse the abstract syntax tree (AST) of each Go file. The main functionality includes:

  1. Parsing Package Files: The program reads and parses all Go files within a given directory, creating an AST for each file.

  2. Identifying Struct Definitions: It searches through the AST to find all declarations of struct types.

  3. Preserving Comments: The program retains comments that are associated with the struct definitions and their fields.

  4. Formatting and Printing Structs: The struct types, along with their fields and associated comments, are formatted to resemble the original Go code. The program uses the go/format package to ensure that the output closely matches the syntax and style of handwritten Go code.

  5. Output: The program outputs the struct definitions to the standard output (console), allowing users to see the struct types and associated comments in a readable format.

The program is invoked by running the main.go file with the -path flag set to the path of the Go package directory to be analyzed. The output can be used for documentation purposes, code reviews, or as a reference when working with existing codebases.

(more…)

Ordinary yet Confident: Why I Dislike Yang Li

In this diverse society, Yang Li, as a stand-up comedian, has gained widespread attention with her sharp wit and unique perspective. Her phrase "He is so ordinary, yet so confident" not only quickly became popular among netizens but also attracted many businesses to invite her for endorsements, which sparked intense public discussions. People, from their respective standpoints, have expressed support or opposition to the act of businesses extending endorsement deals to her. However, in my view, this debate has been fraught with risks from the outset.

(more…)

说说“爱情”,某投江事件有感

在近期的网络热议中,一位作为游戏代练而被一些人所知的青年,在一场情感的漩涡中,因感情和财务的双重挫折,做出了悲剧性的决定,结束了自己的生命。在转完最后一笔钱给所谓的“爱人”,标记上“自愿赠予”以表明态度后不久,他选择了用江水作为自己的最后留言。

(more…)

HBase Basic Introduction and Some Practical Principles

Apache HBase is a high-performance, open-source, distributed NoSQL database designed specifically for the Hadoop ecosystem, especially suitable for scenarios that require fast random read and write access to large datasets. This article will introduce the basics of HBase and use business scenarios of Users, Jobs, and their Subtasks to illustrate related concepts.

(more…)

有个校友

我们中学也有出过不少院士。不过一般就是校史里面列一个数字,名字都不全。但是,学校里面呢,有两个雕像。一个是大门附近的广场上,有个孔子立像。大概但凡是搞教育的,都拿这个形象其实都有点模糊的做个招牌吧。

(more…)