Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix C function by gopsutil_v3_ #1176

Merged
merged 1 commit into from Nov 30, 2021

Conversation

PierreF
Copy link
Contributor

@PierreF PierreF commented Nov 10, 2021

Fix #1175

With this hopefully unique enough prefix, the C functions defined by gopsutil should not longer conflict with either version 2 of gopsutil or another CGO library

With this change, the following program works:

package main

import (
	"fmt"
	v2disk "github.com/shirou/gopsutil/disk"
	v2host "github.com/shirou/gopsutil/host"
	v3disk "github.com/shirou/gopsutil/v3/disk"
	v3host "github.com/shirou/gopsutil/v3/host"
)

func main() {
	fmt.Println(v3host.SensorsTemperatures())
	fmt.Println(v3disk.IOCounters())
	fmt.Println(v2host.SensorsTemperatures())
	fmt.Println(v2disk.IOCounters())
}

This should avoid conflict between both:
* Version 2 of gopsutil
* Other library in version 3 that define the same C function
@shirou
Copy link
Owner

shirou commented Nov 13, 2021

Thank you so much. But we will terminate version 2 on end of this month (PR: #1174). After that, the name will be no longer conflicts. Users who cannot migrate to v3 will be using v2 and v3 at the same time, which may cause conflicts. However, we want to encourage people to migrate to v3.

@PierreF
Copy link
Contributor Author

PierreF commented Nov 15, 2021

In my use case, this will means I can't upgrade to v3 yet, because I indirectly depend on v2.
I'll try to push the v3 on the dependency that use v2.

@mx-psi
Copy link
Contributor

mx-psi commented Nov 30, 2021

I think as @PierreF mentioned on their issue this would be useful to avoid conflicts with any other package, not just v2

Note that this conflict is not necessary limited to version 2 and version 3 of gopsutil. If any other package define the same C function (e.g. version 2 of gopsutil and github.com/lufia/iostat, which both define readdrivestat) a conflict also occur :(

Copy link
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with any other package, not just v2

Understand, agreed. Then, I will merge this PR. But after #1174 merged, please forgive us to remove "v3" from the name, like "gopsutil_readdrivestat".

Thank you for your kind contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 2 and 3 of the library should have different symbol names
3 participants