From caa4072279263f7c50b16374f42c99cd342ee3fa Mon Sep 17 00:00:00 2001 From: Torin Sandall Date: Tue, 21 Apr 2020 08:46:09 -0400 Subject: [PATCH] ast: Rename UUID symbol to avoid confusion Also remove the prefix on the cache key since it's not needed (the type alias is enough to prevent conflicts, e.g., uuidCachingKey("X") != "X".) Signed-off-by: Torin Sandall --- ast/builtins.go | 8 ++++---- topdown/uuid.go | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ast/builtins.go b/ast/builtins.go index d285c32214..e6a0bc9f12 100644 --- a/ast/builtins.go +++ b/ast/builtins.go @@ -211,8 +211,8 @@ var DefaultBuiltins = [...]*Builtin{ // Units UnitsParseBytes, - // Uuid - UUID, + // UUIDs + UUIDRFC4122, } // BuiltinMap provides a convenient mapping of built-in names to @@ -990,8 +990,8 @@ var UnitsParseBytes = &Builtin{ * Type */ -// UUID returns a version 4 uuid string -var UUID = &Builtin{ +// UUIDRFC4122 returns a version 4 UUID string. +var UUIDRFC4122 = &Builtin{ Name: "uuid.rfc4122", Decl: types.NewFunction( types.Args(types.S), diff --git a/topdown/uuid.go b/topdown/uuid.go index e365f2b746..d2bf7261a3 100644 --- a/topdown/uuid.go +++ b/topdown/uuid.go @@ -13,11 +13,9 @@ import ( type uuidCachingKey string -func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error { - var cachingKey = uuidCachingKey("UUID-" + args[0].Value.String()) - +func builtinUUIDRFC4122(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error { + var cachingKey = uuidCachingKey(args[0].Value.String()) id, ok := bctx.Cache.Get(cachingKey) - var uuidv4 *ast.Term if !ok { @@ -39,5 +37,5 @@ func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) err } func init() { - RegisterBuiltinFunc(ast.UUID.Name, builtinUUID) + RegisterBuiltinFunc(ast.UUIDRFC4122.Name, builtinUUIDRFC4122) }