You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

xid_utils.go 396 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122
  1. package xid_utils
  2. import (
  3. "context"
  4. "github.com/seata/seata-go/pkg/common/model"
  5. )
  6. func GetXID(ctx context.Context) string {
  7. xid := ctx.Value(model.XID)
  8. if xid == nil {
  9. return ""
  10. }
  11. return xid.(string)
  12. }
  13. func HasXID(ctx context.Context) bool {
  14. return GetXID(ctx) != ""
  15. }
  16. func SetXID(ctx context.Context, xid string) context.Context {
  17. return context.WithValue(ctx, model.XID, xid)
  18. }

Go Implementation For Seata