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