Implement the PSIStatsForResource function and the parsePSIStats function within the /app/ directory to manage and parse Pressure Stall Information (PSI) statistics.
Requirements:
PSIStatsForResource Function:
This function takes a string parameter representing the resource type (e.g., "cpu", "memory", "io").
It returns a struct containing two fields: Some and Full. Each of these fields is expected to be of type *PSILine.
The function should behave as follows:
For resource type "fake":
It should return an error indicating that the resource does not have PSI statistics.
Both Some and Full should be nil.
For resource type "cpu":
The Some field should not be nil and must contain specific values:
Avg10: 0.1
Avg60: 2.0
Avg300: 3.85
Total: 15
The Full field must be nil.
For resources "memory" and "io":
Both Some and Full fields should not be nil and must contain specific values:
Some:
Avg10: 0.1
Avg60: 2.0
Avg300: 3.85
Total: 15
Full:
Avg10: 0.2
Avg60: 3.0
Avg300: 4.95
Total: 25
parsePSIStats Function:
This function takes a resource type (string) and an io.Reader as input and returns a struct containing the parsed statistics or an error.
It should handle the following cases:
If the input contains an unknown measurement type or malformed data, it should return an error and ensure that both Some and Full fields in the returned struct are nil.
The parsing logic should correctly interpret valid PSI statistics and correctly populate the Some and Full fields when the provided data is valid.
Please ensure that the functions are implemented in a manner that adheres to Go conventions and best practices.
Important: declare your solution in package procfs (the test file uses package procfs, so the implementation must use the matching package name).