You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2022/10/13 18:39:53 UTC

[GitHub] [thrift] dcelasun commented on a diff in pull request #2708: THRIFT-5650: Implement UUID in Go library

dcelasun commented on code in PR #2708:
URL: https://github.com/apache/thrift/pull/2708#discussion_r994995568


##########
lib/go/thrift/uuid.go:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import (
+	"encoding/hex"
+	"fmt"
+)
+
+// Tuuid is a minimal implementation of UUID for thrift's read/write operations.
+//
+// This implementation only covers read/write in various thrift protocols.
+// If you need to generate/manipulate/etc. an UUID,
+// you likely would need a third party UUID library instead.
+//
+// This type should be directly cast-able with most popular third party UUID
+// libraries.
+// For example, assuming you are using
+// https://pkg.go.dev/github.com/google/uuid to generate a v4 UUID for an
+// optional thrift field:
+//
+//	id, err := uuid.NewRandom()
+//	if err != nil {
+//	  // TODO: handle errors
+//	}
+//	myRequest.Uuid = thrift.Pointer(thrift.Tuuid(id))
+type Tuuid [16]byte

Review Comment:
   Agreed. It's not pretty, but it's better to use `UUID` for the other one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org