I had the idea of adding a sync.WaitGroup
Limit(max int)
function to resrict the number of the WaitGroup
counter.
So I opened the waitgroup.go
file in go/src/sync
and made the changes, saved the file and tried testing it in a main.go file on my desktop. When I ran the file, it says:
$ go run main.go
wg.Limit undefined (type sync.WaitGroup has no field or method Limit)
To fix this error message, I copied the folder from go/src/sync
into the folder on my desktop containing my main.go
file and changed the import from sync
to ./sync
.
After running go run main.go
this time, I got the following output:
$ go run main.go
sync\mutex.go:14:2: use of internal package not allowed
sync\pool.go:8:2: use of internal package not allowed
syncwmutex.go:8:2: use of internal package not allowed
sync\waitgroup.go:8:2: use of internal package not allowed
To fix these messages, I copied go/src/internal
into the folder on my desktop containing my main.go
file and I modified all the files in ./sync
that reference internal/..
to ./internal/..
I run it again and I get the following output:
$ go run main.go
# _/C_/.../sync
sync\mutex.go:20: missing function body for "throw"
sync\pool.go:66: missing function body for "fastrand"
sync\pool.go:249: missing function body for "runtime_registerPoolCleanup"
sync\pool.go:250: missing function body for "runtime_procPin"
sync\pool.go:251: missing function body for "runtime_procUnpin"
syncuntime.go:14: missing function body for "runtime_Semacquire"
syncuntime.go:17: missing function body for "runtime_SemacquireMutex"
syncuntime.go:23: missing function body for "runtime_Semrelease"
syncuntime.go:36: missing function body for "runtime_notifyListAdd"
syncuntime.go:39: missing function body for "runtime_notifyListWait"
syncuntime.go:39: too many errors
How can I implement my simple idea by modifying the source files of go/src
without receiving these errors?