Skip to content

Commit d21c06f

Browse files
caxu-rhacornett21
authored andcommitted
Update code to use new generics and language features
Signed-off-by: Caleb Xu <caxu@redhat.com>
1 parent 17bdb58 commit d21c06f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

cmd/docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func init() {
2424
}
2525

2626
func docsRun(cmd *cobra.Command, args []string) {
27-
doctypes := map[string]interface{}{
27+
doctypes := map[string]any{
2828
"man": doc.GenManTree,
2929
"markdown": doc.GenMarkdownTree,
3030
"rest": doc.GenReSTTree,

version/version_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ var _ = Describe("version package utility", func() {
3333
// this in Preflight Results.
3434
Context("When using a VersionContext", func() {
3535
It("should have JSON struct tags on fields", func() {
36-
nf, nexists := reflect.TypeOf(&Version).Elem().FieldByName("Name") // The struct key!
36+
nf, nexists := reflect.TypeFor[VersionContext]().FieldByName("Name") // The struct key!
3737
Expect(nexists).To(BeTrue())
3838
Expect(string(nf.Tag)).To(Equal(`json:"name"`)) // the tag
3939

40-
vf, vexists := reflect.TypeOf(&Version).Elem().FieldByName("Version")
40+
vf, vexists := reflect.TypeFor[VersionContext]().FieldByName("Version")
4141
Expect(vexists).To(BeTrue())
4242
Expect(string(vf.Tag)).To(Equal(`json:"version"`))
4343

44-
cf, cexists := reflect.TypeOf(&Version).Elem().FieldByName("Commit")
44+
cf, cexists := reflect.TypeFor[VersionContext]().FieldByName("Commit")
4545
Expect(cexists).To(BeTrue())
4646
Expect(string(cf.Tag)).To(Equal(`json:"commit"`))
4747
})
4848

4949
It("should only have three struct keys for tests to be valid", func() {
50-
keys := reflect.TypeOf(Version).NumField()
50+
keys := reflect.TypeFor[VersionContext]().NumField()
5151
Expect(keys).To(Equal(3))
5252
})
5353
})

0 commit comments

Comments
 (0)