M
M
ML2017-02-10 12:32:54
go
ML, 2017-02-10 12:32:54

return dynamic type golang?

For example, there is a function

func is_page_name( name string ) string {
switch name {
case "page1":
return name
break
default:
return false
}
}

There will be an error, as the output should be a string, but a bool is returned, what to do?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
X
xotkot, 2017-02-10
@staffID

well so return string who hinders? for example, instead of false, return an empty string return ""
or you can increase the number of returned parameters of this function by adding bool, for example:

func is_page_name( name string ) string, bool {
switch name {
case "page1":
return name, true
break
default:
return "", false
}
}

I
Igor Vorotnev, 2017-09-27
@AzaBroflovski

If multilingual is mirrored - each page or article / news has a translation into another language, then one site and a multilingual plugin is WPML (paid) or Polylang (free, paid add-ons).
If the content (site structure, pages, posts, etc.) differs between language versions, then WordPress Multisite.
Throw everything else out of your head.

A
Aligatro, 2017-09-27
@Aligatro

It is not entirely clear why to fence gardens with different engines or multisite, then you are tormented by administrating / correcting bugs.
I advise you to translate the interface - https://codex.wordpress.org/I18n_for_WordPress_Dev...
To translate posts / pages / taxonomies and other things - https://ru.wordpress.org/plugins/polylang/

P
Pavel, 2017-09-27
@mrusklon

Why not use plugins? https://ru.wordpress.org/plugins/tags/multilanguage/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question