3 ms·
That's no different to importing a module in Perl. If you want to know what's in that module then you read the source of it. > I understand all of that. Power_
by hnlmorg 6y ago
That's no different to importing a module in Perl. If you want to know what's in that module then you read the source of it.
> I understand all of that. Power_state, display the help, power status description etc, but prometheus.NewGaugeVec -- great. What is it? Where do I find this?
It's a function in the module `prometheus`: "github.com/prometheus/client_golang/prometheus"
It's the same thing as the following Perl code:
use Prometheus;
use Prometheus::Log;
use Prometheus::Find;
use Prometheus::View;
use vmware::govmomi::vim25::mo;
use mware::govmomi::vim25::types;
my %prometheusHostPowerState
= prometheus::NewGaugeVec(prometheus->GaugeOpts{
"Namespace" => $namespace,
"Subsystem" => "host",
"Name" => "power_state",
"Help" => "poweredOn 1, poweredOff 2, standBy 3, other 0",
}, @("host_name");
As you can see the code is actually really similar between the two languages in that regard. Bare in mind I'm not suggesting that the languages themselves are similar, eg how modules are created, methods written and arrays are handled are clearly different. But the concept of reusable imported modules and properties in a struct/hash are ostensibly the same.
Disclaimer: I've not written much Perl in the last 3 years so I might have gotten some of the syntax slightly wrong. But it should be close enough for demo purposes.
- doublerabbit 6y agoThen it would be fair to say I can't grasp the new-modern use of github module method then the traditional where prometheus.pm exists on disk and I can trace,trap and edit on the fly. With the line above, prometheus::NewGaugeVec. I know it's related to the Prometheus module, NewGaurgeVec subroutine. I'm not a programmer, I'm a systems admin who job is to take requests of such "we need a vmware exporter, I have this. Make it work".
- hnlmorg 6y agoThe "new-modern use of a github module" is the same as for Perl. If a module isn't in CPAN you have to manually download and place in your project directory. Go just does this for you. And the module files in Go are on disk -- there's no way you could compile the project if half the source code wasn't on disk. I think you'd probably have enjoyed Go more in the "old" days when $GOPATH was required and all modules were downloaded into your $GOPATH as it was more explicit were modules were and in a way it felt a little more like Perl with the file system being a more prominent part of modules. This was a very unpopular pattern for developers so things have moved on somewhat with modules now being pulled into a package directory. Personally I preferred the $GOPATH days too but it's fair to say the modules are still on disk.