In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Direct code:
Ackage mainimport "fmt" / / now there are classrooms and dormitories, with two classrooms, windows two meters high and a dormitory door. The window is one meter high type Room struct {doorNum int windowHeight int} func (r * Room) showRoomInfo () {fmt.Println ("door num:", r.doorNum, "door windowHeight:", r.windowHeight)} type RoomBuilder interface {build () * Room} func BuildRoom (builder RoomBuilder) * Room {return builder.build ()} type Cla***oomBuilder struct {} func (* Cla***oomBuilder) build () * Room {return & Room {2 2}} type DormitoryBuilder struct {} func (* DormitoryBuilder) build () * Room {return & Room {1,1}} func main () {room: = BuildRoom (& Cla***oomBuilder {}) room.showRoomInfo () room = BuildRoom (& DormitoryBuilder {}) room.showRoomInfo () / similarly, we need a living room, a door without windows. You can write a living room builder / / the example here is very simple, but in practice, the build function may deal with very complex things. Through the builder mode, you can separate the specific / / instance from the creation process, so it is easy to extend and replace the creation process} github long-term update: https://github.com/fanux/gopatterns
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.