[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>
2 files changed
tree: 99e63b6a24aff40fb9523ba36b0b6a60819e6b3b
  1. appengine/
  2. auth/
  3. buildbucket/
  4. cipd/
  5. client/
  6. common/
  7. config/
  8. dm/
  9. examples/
  10. gce/
  11. grpc/
  12. hardcoded/
  13. infra/
  14. logdog/
  15. luci_notify/
  16. lucicfg/
  17. lucictx/
  18. machine-db/
  19. milo/
  20. mmutex/
  21. mp/
  22. scheduler/
  23. scripts/
  24. server/
  25. starlark/
  26. tokenserver/
  27. tools/
  28. tumble/
  29. vpython/
  30. web/
  31. .travis.yml
  32. AUTHORS
  33. codereview.settings
  34. CONTRIBUTING.md
  35. CONTRIBUTORS
  36. LICENSE
  37. OWNERS
  38. pre-commit-go.yml
  39. PRESUBMIT.py
  40. README.md
README.md

luci-go: LUCI services and tools in Go

GoDoc

Installing

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

Contributing uses the same flow as Chromium contributions.