The two most basic file path operations

Report a typo

Arnold wants to create a very simple Go program. It should take as input a certain path, and it should output the path's base and the path's directory.

Please help Arnold write the required code and use the proper functions from the filepath package that return the path's base and the path's directory.

Sample Input 1:

/home/User/GolandProjects/awesomeProject/main.go

Sample Output 1:

Base: main.go
Dir: /home/User/GolandProjects/awesomeProject
Write a program in Go
package main

import (
"fmt"
"path/filepath"
)

func main() {
// DO NOT delete these two lines! they take a certain 'path' as an input
var path string
fmt.Scanln(&path)

// Help Arnold call the correct functions from the filepath pkg below
// To get and print the "path's base" and the "path's dir"!
fmt.Println("Base:", ?)
fmt.Println("Dir:", ?)
}
___

Create a free account to access the full topic