What is the meaning of a question mark in bash variable parameter expansion as in ${var?}?

What is the meaning of a bash variable used like this: ${Server?} Answer It works almost the same as (from the bash manpage): ${parameter:?word} Display Error if Null or Unset. If parameter is null or unset, the expansion of word (or a message to that effect if word is not present) is written to the … Read more

C++ Error ‘nullptr was not declared in this scope’ in Eclipse IDE

I am running Eclipse Helios and I have g++-4.6 installed. Hope I am not wrong that g++4.6 implements C++ 11 features. I have created a C++ project which uses the nullptr and auto keywords. The build gives the following errors:- ../{filename}.cpp:13:13: error: ‘nullptr’ was not declared in this scope ../{filename}.cpp:14:2: warning: ‘auto’ will change meaning … Read more

Regex with replace in Golang

I’ve used regexp package to replace bellow text {% macro products_list(products) %} {% for product in products %} productsList {% endfor %} {% endmacro %} but I could not replace “products” without replace another words like “products_list” and Golang has no a func like re.ReplaceAllStringSubmatch to do replace with submatch (there’s just FindAllStringSubmatch). I’ve used … Read more

Hiding nil values, understanding why Go fails here

I fail to understand how to correctly assure that something is not nil in this case: package main type shower interface { getWater() []shower } type display struct { SubDisplay *display } func (d display) getWater() []shower { return []shower{display{}, d.SubDisplay} } func main() { // SubDisplay will be initialized with null s := display{} … Read more

How to pass variable length arguments as arguments on another function in Golang?

How to pass variable length arguments in Go? for example, I want to call func MyPrint(format string, args …interface{}) { fmt.Printf(“[MY PREFIX] ” + format, ???) } // to be called as: MyPrint(“yay %d”, 213) // or MyPrint(“yay”) // or MyPrint(“yay %d %d”,123,234) Answer Ah found it…functions that accept variable length arguments are called Variadic … Read more