# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ "$SHELL" = "/bin/bash" ]; then
    # include .bashrc if it exists and we are not in a subshell
    # Check if .bashrc exists
    if [ -f "$HOME/.bashrc" ]; then
        # Check if we are in a login shell (indicated by -l in the shell options)
        if ! shopt -oq posix; then # Check if not running in POSIX mode (usually implies a login shell)
            . "$HOME/.bashrc"
        fi
    fi
elif [ "$SHELL" = "/bin/zsh" ]; then
    if [ -f "$HOME/.zshrc" ]; then
        . "$HOME/.zshrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

# Use stable nvm version if available
if command -v nvm &> /dev/null; then
    nvm use stable
fi

# Add Go directories to PATH
if [ -d "/usr/local/go/bin" ] ; then
    PATH="/usr/local/go/bin:$PATH"
fi

if [ -d "$HOME/go/bin" ] ; then
    PATH="$HOME/go/bin:$PATH"
fi

# Add Go version-specific paths if they exist
shopt -s nullglob 2>/dev/null || setopt nullglob 2>/dev/null || true
for go_path in /usr/lib/go-*/bin /usr/lib/go/bin; do
    if [ -d "$go_path" ] ; then
        PATH="$go_path:$PATH"
    fi
done
shopt -u nullglob 2>/dev/null || unsetopt nullglob 2>/dev/null || true

export GOROOT=/usr/local/go
