- You need to design the data model for your data. You have several alternatives here but most simple one is struct with three fields: for name, for department and for college. The data is in the array. Read about data structures here: https://golang.org/doc/effective_go.html#data
- You need to initialise your data structure. Maybe you have the input in text file? Then you can use methods of the fmt or bufio to read it.
- They you need to read the command line arguments - get them from os.Args.
- The filter data and output the result. This is a simple
for
loop over the slice with one if
in it. Use Println to output the result.
Sample code:
package main
import (
. "fmt"
"os"
)
type Record struct {
Name string
Department string
College string
}
func main() {
records := make([]Record, 0)
// add records
records = append(records, Record{"A1", "CSE", "SR1"})
...
// get filter from os.Args
filter := ...
for _, v := range records {
if v.College == filter {
Println(v.Name, v.Department)
}
}
}
P.S. If you ask yourself why the question is downvoted (not by me) - because it does not demonstrate the you actually tried to solve the problem. See https://stackoverflow.com/help/on-topic