转到:内联字符串连接

I need to call os.Open to open a file. I have the path ./XML/ and the filename foo.xml, which changes each time. That is I have an array of xml files read from a dir which I am trying to open one at a time (or threaded, doesn't matter).

I need to simple add ./XML/ to SOMETHING.xml. In Java this is trivial,

String a = "whatever", b = "whatever";
doSomething(a + b);

How is this done in Go? Google has failed me.

file, err := os.Open(????????????)

The most portable way to do path concatenation is by using filepath.Join:

import "path/filepath"

file, err := os.Open(filepath.Join("XML", fileinfo.Name()))