You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/05/10 15:30:42 UTC

[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #503: FileSystemServiceDiscovery

hxmhlt commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r422660605



##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {

Review comment:
       每一个func前都需要添加注释,格式为
   // Create(the first word have to be same as your func name)...

##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {
+	if file == nil || file.Path == "" {
+		return nil, perrors.Errorf("cannot create flock on empty path")
+	}
+	lock, e := os.Create(file.Path)

Review comment:
       len(file.Path)==0 来判断字符串是否为空更好

##########
File path: registry/filesystem/file_lock.go
##########
@@ -0,0 +1,83 @@
+/*
+ * 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 filesystem
+
+import (
+	"github.com/apache/dubbo-go/common/logger"

Review comment:
       import需要分段,看下其他文件的依赖导入格式吧~




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org