MCPcopy Index your code
hub / github.com/coder/envbox / parsePasswdEntry

Function parsePasswdEntry

xunix/user.go:44–60  ·  view source on GitHub ↗
(entry string)

Source from the content-addressed store, hash-verified

42}
43
44func parsePasswdEntry(entry string) (*User, error) {
45 entry = strings.TrimSpace(entry)
46 fields := strings.Split(entry, ":")
47 if len(fields) < 7 {
48 return nil, xerrors.Errorf("user info (%s) contained an unexpected number of fields", fields)
49 }
50
51 return &User{
52 User: user.User{
53 Username: fields[0],
54 Uid: fields[2],
55 Gid: fields[3],
56 HomeDir: fields[5],
57 },
58 Shell: fields[6],
59 }, nil
60}

Callers 1

ParsePasswdFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected