Here is the the program
package main

import (
        "fmt"
        "log"
        "os/user"
)

func main() {
    username, err := user.Current()
    if err != nil {
        log.Fatal(err)
    }
        if username != "root" || username != "someuser" {
                fmt.Println("You are currently logged in as:" + username)
                fmt.Println("You need to be root or someuser")
        }


}

Here is the output
go run user.go
# command-line-arguments
./user.go:14:14: invalid operation: username != "root" (mismatched types 
*user.User and string)
./user.go:14:36: invalid operation: username != "someuser" (mismatched 
types *user.User and string)
./user.go:15:53: invalid operation: "You are currently logged in as:" + 
username (mismatched types string and *user.User)

I am not sure how to handle mismatched types string and *user.User. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to