commit | 2e46e5dee4bb0e3ce4367435865925348fde82bd | [log] [tgz] |
---|---|---|
author | Vadim Shtayura <vadimsh@chromium.org> | Wed Dec 12 00:02:01 2018 |
committer | Commit Bot <commit-bot@chromium.org> | Wed Dec 12 00:02:01 2018 |
tree | 99e63b6a24aff40fb9523ba36b0b6a60819e6b3b | |
parent | ae9d4a1dff081f2309f4bcbc61632b9ed50762b0 [diff] |
[starlark] Add genstruct(...) and ctor(...) builtins. They can be used to create structs "tagged" with a symbol. It's not quite like a typed struct (each individual object still can have arbitrary fields), but pretty close: mystruct = genstruct("mystruct") s = mystruct(a=1, b=2) assert.eq(ctor(s), mystruct) assert.eq(ctor(1), None) assert.eq(ctor(struct(a=1, b=2)), "struct") Can be used to add some sort of type safety to Starlark libraries. Note that using type(strct) is insufficient, since it always returns "struct". R=nodir@chromium.org, iannucci@chromium.org BUG=833946 Change-Id: I65abc0594441367a7ecd3c0faa05c06499d61c30 Reviewed-on: https://chromium-review.googlesource.com/c/1370693 Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Reviewed-by: Nodir Turakulov <nodir@chromium.org> Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
LUCI Go code is meant to be worked on from an Chromium infra.git checkout, which enforces packages versions and Go toolchain version. First get fetch via depot_tools.git then run:
fetch infra cd infra/go eval `./env.py` cd src/go.chromium.org/luci
Contributing uses the same flow as Chromium contributions.