public Function createFunctionIfMissing(String name, Namespace ns, Address addr) {
		Function function = program.getListing().getFunctionAt(addr);
		if (function == null) {
			if (!program.getMemory().getLoadedAndInitializedAddressSet().contains(addr)) {
				Msg.warn(this, "Unable to create function not contained within loaded memory: %s@%s"
						.formatted(name, addr));
				return null;
			}
			try {
				function = program.getFunctionManager()
						.createFunction(name, ns, addr, new AddressSet(addr), SourceType.IMPORTED);
			}
			catch (OverlappingFunctionException | InvalidInputException
					| IllegalArgumentException e) {
				Msg.error(this, e);
				return null;
			}
		}
		else {
			try {
				if (!containsSymbolName(addr, name)) {
					function.setName(name, SourceType.IMPORTED);
				}
				function.setParentNamespace(ns);
			}
			catch (InvalidInputException | DuplicateNameException | CircularDependencyException e) {
				Msg.error(this, e);
			}
		}
		return function;
	}
Creates a default function at the specified address.

@param name name of the new function
@param ns namespace function should be in
@param addr address of the new function
@return {@link Function} that was created
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/structmapping/MarkupSession.java