Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created May 15, 2019 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDanisch/64c3b0a36d3a2981fb3404b7115ee89e to your computer and use it in GitHub Desktop.
Save SimonDanisch/64c3b0a36d3a2981fb3404b7115ee89e to your computer and use it in GitHub Desktop.
function searchmodule(mod, name, visited = Set())
mod in visited && return nothing
push!(visited, mod)
string(mod) == string(name) && return mod
if mod isa Module
name == nameof(mod) && return mod
for sym in names(mod)
res = searchmodule(getfield(mod, sym), name, visited)
res !== nothing && return res
end
end
return nothing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment