From 25ab223c07152a41f74b37ff667f6fdd329b2fe6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 13 Jan 2025 05:56:45 -0600 Subject: [PATCH] testing mutex locks and Marshal() function panic --- Makefile | 2 +- goDep.proto | 4 ++-- repo.new.go | 4 ++-- repo.proto | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1696e6d..f7434ed 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ clean: # refs.proto gitTag.pb.go: gitTag.proto - autogenpb --proto gitTag.proto + autogenpb --proto gitTag.proto --mutex-name "john" goDep.pb.go: goDep.proto autogenpb --proto goDep.proto diff --git a/goDep.proto b/goDep.proto index 72d32e7..8dde9f3 100644 --- a/goDep.proto +++ b/goDep.proto @@ -8,7 +8,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // global settings for autogenpb `autogenpb:mutex` -message GoDep { // `autogenpb:nomutex` +message GoDep { // `autogenpb:2nomutex` string hash = 1; // `autogenpb:unique` `autogenpb:sort` // md5sum/hash value from the go.sum file google.protobuf.Timestamp ctime = 2; // get the go date from 'go list' ? string version = 3; // v1.2.2 @@ -16,7 +16,7 @@ message GoDep { // `autogenpb:nomutex` string goVersion = 5; // version of golang the developer used to make this package version } -message GoDeps { // `autogenpb:nomutex` +message GoDeps { // `autogenpb:2nomutex` string uuid = 1; // `autogenpb:uuid:` string version = 2; // `autogenpb:version` repeated GoDep goDeps = 3; // `autogenpb:unique` `autogenpb:sort` diff --git a/repo.new.go b/repo.new.go index fa39dfa..c073fad 100644 --- a/repo.new.go +++ b/repo.new.go @@ -50,8 +50,8 @@ func (all *Repos) NewGoRepo(fullpath string, gopath string) (*Repo, error) { // enforces GoPath is unique func (all *Repos) AppendByGoPath(newr *Repo) bool { - all.Lock.RLock() - defer all.Lock.RUnlock() + all.RLock() + defer all.RUnlock() for _, r := range all.Repos { if r.GoInfo.GoPath == newr.GoInfo.GoPath { diff --git a/repo.proto b/repo.proto index b509877..83c7206 100644 --- a/repo.proto +++ b/repo.proto @@ -11,7 +11,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // global settings for autogenpb `autogenpb:mutex` -message Repo { // `autogenpb:marshal` `autogenpb:nomutex` +message Repo { // `autogenpb:marshal` `autogenpb:2nomutex` string fullPath = 1; // `autogenpb:unique` `autogenpb:sort` // the actual path to the .git directory: '/home/devel/golang.org/x/tools' string masterBranchName = 3; // git 'main' or 'master' branch name string develBranchName = 4; // whatever the git 'devel' branch name is @@ -43,7 +43,7 @@ message Repos { // `autogenpb:marshal` `autogenpb:sort` } // should it be done this way? -message GitTimes { // `autogenpb:nomutex` +message GitTimes { // `autogenpb:2nomutex` google.protobuf.Timestamp lastPull = 1; // last time a git pull was done google.protobuf.Timestamp lastUpdate = 2; // when was ReloadGit() last done google.protobuf.Timestamp lastDirty = 3; // last time CheckDirty() was run @@ -56,7 +56,7 @@ message GitTimes { // `autogenpb:nomutex` } // this is probably better. think about moving to this instead -message GoInfo { // `autogenpb:nomutex` +message GoInfo { // `autogenpb:2nomutex` string goPath = 1; // the logical path as used by golang: 'go.wit.com/apps/helloworld' string desc = 2; // what is this repo? bool goLibrary = 3; // is this a golang library?