SkillAgentSearch skills...

GoReflectionTalk

GopherCon 2016

Install / Use

/learn @candysmurf/GoReflectionTalk
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Reflection - Standard Library

Developers are often told reflection is bad and should be avoided. However, when reflection can help reduce the amount of code needed to solve a problem, it should be considered. Reducing complexity while preserving maintainability must always be a priority. Reflection can be a tool that helps makes this possible. In this talk I am going to show you the power and elegance of the reflection package.

https://candysmurf.github.io/GoReflectionTalk

Links

http://blog.golang.org/laws-of-reflection

Code Review

Basics

Example shows how to reflect over a struct type value.
Struct Types (Go Playground)

Example shows how to reflect over a slice of struct type values.
Slices (Go Playground)

Example shows how to reflect over a map of struct type values.
Maps (Go Playground)

Example shows how to reflect over a struct type pointer.
Pointers (Go Playground)

Interfaces

Example shows how to reflect over a struct type value that is stored inside an interface value.
Struct Types (Go Playground)

Example shows how to reflect over a slice of struct type values that are stored inside an interface value.
Slices (Go Playground)

Example shows how to reflect over a map of struct type values that are stored inside an interface value.
Maps (Go Playground)

Example shows how to reflect over a struct type pointer that is stored inside an interface value.
Pointers (Go Playground)

Inspection / Decoding

Example shows how to inspect a structs fields and display the field name, type and value.
Struct Types (Go Playground)

Example shows how to use reflection to decode an integer.
Integers (Go Playground)


All material is licensed under the Apache License Version 2.0, June 2016.

Related Skills

View on GitHub
GitHub Stars26
CategoryDevelopment
Updated3y ago
Forks10

Languages

CSS

Security Score

55/100

Audited on Jun 16, 2022

No findings