github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/src/os/user/lookup_plan9.go (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package user
     6  
     7  import (
     8  	"fmt"
     9  	"io/ioutil"
    10  	"os"
    11  	"syscall"
    12  )
    13  
    14  // Partial os/user support on Plan 9.
    15  // Supports Current(), but not Lookup()/LookupId().
    16  // The latter two would require parsing /adm/users.
    17  const (
    18  	userFile = "/dev/user"
    19  )
    20  
    21  func current() (*User, error) {
    22  	ubytes, err := ioutil.ReadFile(userFile)
    23  	if err != nil {
    24  		return nil, fmt.Errorf("user: %s", err)
    25  	}
    26  
    27  	uname := string(ubytes)
    28  
    29  	u := &User{
    30  		Uid:      uname,
    31  		Gid:      uname,
    32  		Username: uname,
    33  		Name:     uname,
    34  		HomeDir:  os.Getenv("home"),
    35  	}
    36  
    37  	return u, nil
    38  }
    39  
    40  func lookup(username string) (*User, error) {
    41  	return nil, syscall.EPLAN9
    42  }
    43  
    44  func lookupId(uid string) (*User, error) {
    45  	return nil, syscall.EPLAN9
    46  }