Comments (6)
Hmm, I am not so good at English. Could you tell me what kind of Function name is better for the purpose?
from gopsutil.
You are too modest. :-)
a poor example:
package main
import (
"fmt"
"strings"
)
// Check the target string slice containes src or not
func StringsHas(target []string, src string) bool {
for _, t := range target {
if strings.TrimSpace(t) == src {
return true
}
}
return false
}
// Does src in any string of the target string slice
func StringsFind(target []string, src string) bool {
for _, t := range target {
if strings.Index(t, src) >= 0 {
return true
}
}
return false
}
func main() {
v := []string{
"hello, c",
"hello, unix",
"hello, gnu",
"hello, linux",
"hello, go",
}
test_data := []string{
"hello, c",
"unix",
"Java",
}
for _, s := range test_data {
fmt.Printf("StringsHas(\"%s\", v) = %t\n", s, StringsHas(v, s))
fmt.Printf("StringsFind(\"%s\", v) = %t\n", s, StringsFind(v, s))
}
}
from gopsutil.
Thank you for the suggestion!
golang has the method called strings.Contains to check strings has the substr or not.
If I change your StringsFind
to use strings.Contains
, changing the name to StringsContains
is acceptable?
Sorry for annoying you. But I can not understand well such a nuances. Really.
from gopsutil.
Yes, it's good. I've missed the strings.Contains .
from gopsutil.
I commit the change at b5ffc22. If I have miss understanding, please re-open this issue.
I am very appriciate to have discussion with you. Thank you.
from gopsutil.
It's a nice job, thanks for your share.
from gopsutil.
Related Issues (20)
- The host.Info() function is unable to correctly identify CentOS Stream 8. HOT 1
- Missing FQDN/hostname option for windows HOT 2
- stat.Rdev (variable of type uint32) as uint64 HOT 4
- Adopt a hierarchy for getting distro name/version on Linux
- Mac OS Apple M1 get cpu info failed "no such file or directory" HOT 3
- Using the gopsutil package causes the goland debugger to not work properly (random jumps)
- ProcTotal Inaccurate in `MiscStats` HOT 4
- : Optimization Request: Reducing the Number of windows.OpenProcess Calls When Gathering Name, CreateTime, and PPID HOT 1
- docker container monitor host resource and usage
- [invoker] set the `WaitDelay` to avoid getting indefinitely blocking wait() HOT 1
- Calling disk.Partitions(false) produces different list on Linux to "df" HOT 1
- `ExeWithContext` returns an error with a Go binary on newer versions of macOS HOT 6
- Inaccurate readings of cpu.Percent
- Allow path to net/dev to not be under HOST_PROC
- Windows interrupt signal errror HOT 1
- Crash in createTimeWithContext when run on FreeBSD arm64 HOT 18
- runtime: program exceeds 10000-thread limit HOT 1
- Builds for netbsd arm fail with `undefined: cpuTimes` HOT 4
- Get current working directory on openbsd HOT 3
- TestDisk_partitions fails when there are no physical drives mounted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gopsutil.